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

UnboundLocalError when Okta password is expired #194

Open
kirilyer opened this issue Jun 2, 2022 · 0 comments
Open

UnboundLocalError when Okta password is expired #194

kirilyer opened this issue Jun 2, 2022 · 0 comments

Comments

@kirilyer
Copy link

kirilyer commented Jun 2, 2022

When trying to refresh AWS tokens using an expired Okta password an exception is raised instead of a friendly message to the user.

 > okta-awscli -f -v -d -P <password>
DEBUG - Setting AWS role to arn:aws:iam::<account>:role/<role>
DEBUG - Setting AWS partition to AwsPartition.AWS
DEBUG - Setting AWS profile to default
INFO - App Link set as: https://<org>.okta.com/home/amazon_aws/<...>
INFO - Authenticating to: <org>.okta.com
INFO - Authenticating as: <email>
Traceback (most recent call last):
  File "/path/to/venv/bin/okta-awscli", line 33, in <module>
    sys.exit(load_entry_point('okta-awscli==0.5.4', 'console_scripts', 'okta-awscli')())
  File "/path/to/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/path/to/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/path/to/venv/lib/python3.8/site-packages/oktaawscli/okta_awscli.py", line 141, in main
    get_credentials(
  File "/path/to/venv/lib/python3.8/site-packages/oktaawscli/okta_awscli.py", line 36, in get_credentials
    _, assertion = okta.get_assertion()
  File "/path/to/venv/lib/python3.8/site-packages/oktaawscli/okta_auth.py", line 156, in get_assertion
    self.session_token = self.primary_auth()
  File "/path/to/venv/lib/python3.8/site-packages/oktaawscli/okta_auth.py", line 78, in primary_auth
    return session_token
UnboundLocalError: local variable 'session_token' referenced before assignment

To Reproduce

  1. Have your Okta password expire.
  2. Try to refresh tokens.
  3. Get an exception.

Expected behavior
I would expect to see an error saying the Okta password is expired instead of an exception stack trace.

Output
see above.

Environment (please complete the following information):

  • OS: MacOS Monterey 12.3.1
  • okta-awscli version: 0.5.4
  • Python 3.8.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant