Skip to content

Commit

Permalink
Merge pull request #98 from jimwbaldwin/yawsso-97_refresh_token
Browse files Browse the repository at this point in the history
Resolve auto login issue when refreshToken is missing
  • Loading branch information
victorskl authored Oct 5, 2024
2 parents 18d8021 + 08dca3b commit 5fcd464
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions yawsso/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,22 @@ def append_cli_global_options(cmd: str, profile: dict):


def create_access_token(cached_login):
cmd_create_token = f"{aws_bin} sso-oidc create-token " \
f"--output json " \
f"--client-id {cached_login['clientId']} " \
f"--client-secret {cached_login['clientSecret']} " \
f"--grant-type refresh_token " \
f"--refresh-token {cached_login['refreshToken']}"

create_token_success, create_token_output = u.invoke(cmd_create_token)
if not cached_login.get('refreshToken'):
logger.log(TRACE, "refreshToken not found in cached login.")
return False, ""
else:
cmd_create_token = f"{aws_bin} sso-oidc create-token " \
f"--output json " \
f"--client-id {cached_login['clientId']} " \
f"--client-secret {cached_login['clientSecret']} " \
f"--grant-type refresh_token " \
f"--refresh-token {cached_login['refreshToken']}"
create_token_success, create_token_output = u.invoke(cmd_create_token)

if not create_token_success:
logger.log(TRACE, f"EXCEPTION: '{create_token_output}'")
if not create_token_success:
logger.log(TRACE, f"EXCEPTION: '{create_token_output}'")

return create_token_success, create_token_output
return create_token_success, create_token_output


def get_role_credentials(profile_name, profile, access_token):
Expand Down

0 comments on commit 5fcd464

Please sign in to comment.