AWS CLI works but boto3 reports Token has expired and refresh failed #4119
Labels
bug
This issue is a confirmed bug.
closed-for-staleness
credentials
p3
This is a minor priority issue
response-requested
Waiting on additional information or feedback.
sso
Describe the bug
I have a python script that will work for some time, but eventually, it starts saying "Error when retrieving token from sso: Token has expired and refresh failed". The thing is, the token should still be valid. For example, I can go to the AWS CLI and run
aws s3 ls
and it will list the buckets for my default profile.Expected Behavior
Well this code used to work, I'm not sure what changed external to break it. I might have updated boto3 or maybe the AWS CLI. But since the AWS CLI seems to work with my default profile, I would expect my script to work also.
Current Behavior
Here is my test code
and the output:
but if I run
aws s3 ls
from the CLI, it spits out the s3 buckets using my default profile. So the creds are still valid? or should be?Reproduction Steps
I'm really not sure how to get it into this bad state. But it happened to me on linux and it happened to my other co-worker on windows.
Possible Solution
Well, if I go to the aws cli and I run
aws sso login
. Then the script starts working again? Strange. It seems like something is wrong in how it looks up default credential "chain". But I'm not sure.Additional Information/Context
What my default profile looks like:
SDK version used
1.28.85
Environment details (OS name and version, etc.)
WSL Ubuntu 22.04
The text was updated successfully, but these errors were encountered: