I'm having trouble getting a boto3 client to connect to AWS over SSO. I can sign in and query with the CLI tool:
aws sso login --profile my-profile
aws s3 ls # this works
But when I try to access through boto3, following the top rated answer here, I get an UnauthorizedSSOTokenError
:
import boto3
boto3.setup_default_session(profile_name='my-profile')
s3 = boto3.client('s3')
s3.list_buckets() # this fails
What's going on here? Am I not using boto3 correctly?