After a recent aws-cli update, yawsso breaks with the following exception:
Traceback (most recent call last):
File "$HOME/.local/bin/yawsso", line 8, in <module>
sys.exit(main())
File "$HOME/.local/pipx/venvs/yawsso/lib/python3.8/site-packages/yawsso/cli.py", line 540, in main
credentials = update_profile(profile_name, config)
File "$HOME/.local/pipx/venvs/yawsso/lib/python3.8/site-packages/yawsso/cli.py", line 345, in update_profile
credentials = fetch_credentials(profile_name, profile)
File "$HOME/.local/pipx/venvs/yawsso/lib/python3.8/site-packages/yawsso/cli.py", line 224, in fetch_credentials
cached_login = check_sso_cached_login_expires(profile_name, profile)
File "$HOME/.local/pipx/venvs/yawsso/lib/python3.8/site-packages/yawsso/cli.py", line 215, in check_sso_cached_login_expires
expires_utc = parse_sso_cached_login_expiry(cached_login)
File "$HOME/.local/pipx/venvs/yawsso/lib/python3.8/site-packages/yawsso/cli.py", line 180, in parse_sso_cached_login_expiry
expires_utc = datetime.strptime((cached_login["expiresAt"]), datetime_format_in_sso_cached_login)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '2020-12-28T20:47:20Z' does not match format '%Y-%m-%dT%H:%M:%SUTC'
I am not sure if this is breaking with an aws-cli update since I cannot find anything relevant in its changelog, so I suspect this might be following a server-side change which updates the expiresAt format to ISO 8601.
yawsso can handle this without breaking compatibility with the old UTC format by doing this:
def parse_sso_cached_login_expiry(cached_login):
# older versions of aws-cli might use non-standard format with `UTC` instead of `Z`
expires_at = cached_login["expiresAt"].replace('UTC', 'Z')
datetime_format_in_sso_cached_login = "%Y-%m-%dT%H:%M:%SZ"
expires_utc = datetime.strptime(expires_at, datetime_format_in_sso_cached_login)
return expires_utc
After a recent aws-cli update, yawsso breaks with the following exception:
Relevant issue in aws-java-sdk-v2: https://github.com/aws/aws-sdk-java-v2/issues/2190
I am not sure if this is breaking with an aws-cli update since I cannot find anything relevant in its changelog, so I suspect this might be following a server-side change which updates the
expiresAt
format to ISO 8601.yawsso can handle this without breaking compatibility with the old
UTC
format by doing this: