Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve auto login issue when refreshToken is missing #98

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading