The names of the JSON files in ~/.aws/sso/cache seem random but it turns out they're actually just hex-encoded SHA1 digests of your various SSO start URLs. This means it's not necessary to loop over all the files in ~/.aws/sso/cache to find the one we're looking for – we can just go straight to the right one.
Given a start URL https://d-xxxxxxxxxx.awsapps.com/start, we can expect to find its cached SSO credentials file (if it exists) at ~/.aws/sso/cache/5c26431228bc0d538e12104a3cbc37975e46c8f9.json.
The names of the JSON files in
~/.aws/sso/cache
seem random but it turns out they're actually just hex-encoded SHA1 digests of your various SSO start URLs. This means it's not necessary to loop over all the files in~/.aws/sso/cache
to find the one we're looking for – we can just go straight to the right one.Given a start URL
https://d-xxxxxxxxxx.awsapps.com/start
, we can expect to find its cached SSO credentials file (if it exists) at~/.aws/sso/cache/5c26431228bc0d538e12104a3cbc37975e46c8f9.json
.