[BUG] CC not taking the updated credentials with awsAuthRefresh
Environment
- Platform (select one):
- [ ] Anthropic API
- [X] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.53
- Operating System: macOS 15.5
- Terminal: iTerm2
Bug Description
I set up awsAuthRefresh with a script that uses okta 2FA to refresh my aws credentials in .aws/credentials.
This seems to be hit or miss. It often fails to actually use the refreshed credentials and I have to exit and resume with claude -r.
Added this to my settings.json:
"awsAuthRefresh": "gimme-aws-creds --profile MYPROFILE",
I do see the script being invoked by CC when credentials have expired, I receive the push notification and credentials are updated in .aws/credentials.
However it apparently fails to use the refreshed credentials.
See attached screenshot:
<img width="815" height="320" alt="Image" src="https://github.com/user-attachments/assets/0623ee62-c3a5-4ea1-88bf-cb20f5f17066" />
(Even if ideally I guess we'd like the refresh to be seamless for the user, in this case, given that there's a manual step anyway (the 2FA), it would be great if we could have an explicit command like /refresh-credential to tell CC to go and read again the refreshed IAM credentials from env / credentials file. So that one could also do that manually from another terminal, etc.)
6 Comments
Hi team, I have the same issue and this is the details.
I setup
awsAuthRefreshto./claude/settings.local.jsonlike the below.I added the command(
aws-azure-login --no-prompt) which refreshes and creates a newaws_access_key_id,aws_secret_access_keyandaws_session_tokenwith 1 hour expiration.In claude code, when the session expire, it runs the command (
aws-azure-login --no-prompt).I checked
~/.aws/credentialsand can see the newaws_access_key_id,aws_secret_access_keyandaws_session_tokenare created.But the claude code does not use the new created
aws_access_key_id,aws_secret_access_keyandaws_session_tokenand shows the error like this.This is also not working for me either. I have configured both
awsAuthRefreshandawsCredentialExport. Note, I found that the suggested command forawsCredentialExport:does not work for me. I get this error:
To mitigate this, I created a script to use
aws configure export-credentials --profile "${PROFILE}" --format processandjqto format the output into the JSON format specified for advanced credential configuration. When I run my script, I can verify it gives the proper output:With this working, I have configured my claude settings as follows:
If I launch claude code without any credentials, it successfully logs me in:
<img width="1912" height="442" alt="Image" src="https://github.com/user-attachments/assets/4a552695-6e81-40f3-81ab-5430f368da84" />
However, performing any tasks continue to fail with the same
403 The security token included in the request is invaliderror. Since login was successful, it appears that the credentials are not being exported properly.In the meantime, I am using this bash function in my
~/.zprofileto ensure I'm logged in when I launch claude:I hope this helps.
@leotac and @Yukitada-Ri - we've isolated the issue to an issue preventing
~/.aws/credentialsfrom being reread after update. Thank you both for the detailed posts about your configurations, this was very helpful (turns outaws ssobased flows don't have this same issue). We're working on a patch.@mattscully - thanks as well for posting your configuration. If you're using a predefined (static) profile and
aws sso login, may I suggest this configuration:settings.json
Because you're using an
aws ssoconfiguration, you shouldn't need to explicitly export the credentials viaawsCredentialExport(it's primarily meant for people who have scripts that can't modify.aws/credentials).We've issued a patch for this, which will go out in v1.0.56 or v1.0.57 - I will post here when that's complete.
Released in v1.0.56 today - though it's not tagged as
latestyet.This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.