Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

boto3 - Botocore credentials cache

When i try to get the credentials saved in the cache for the mfa login to aws, i always get prompted the mfa code. But it's correctly saved in the cache when i login. Just never used.

cli_cache = os.path.join(os.path.expanduser('~'), '.aws/cli/cache')

params = {'profile': 'profile-name'}
provider = botocore.session.Session(**params)
provider.get_component('credential_provider').get_provider('assume-role').cache = credentials.JSONFileCache(cli_cache)

session = Session(botocore_session=provider)

Can someone help me with this mfa code being prompted every time?

question from:https://stackoverflow.com/questions/66052035/botocore-credentials-cache

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Ok it's fixed, the code is correct. The issue was on the duration_seconds being different in .aws/credentials than what was set on the role on aws


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...