Skip to content

Instantly share code, notes, and snippets.

@bmehul
Last active August 3, 2022 20:43
Show Gist options
  • Save bmehul/f79342144fd8016ebad533f7d9aba350 to your computer and use it in GitHub Desktop.
Save bmehul/f79342144fd8016ebad533f7d9aba350 to your computer and use it in GitHub Desktop.
Boto3: Get Pool Credentials
import boto3
import sys
def get_pool_credentials(region, identity_pool):
client = boto3.client('cognito-identity', region_name=region)
_id = client.get_id(IdentityPoolId=identity_pool)
_id = _id['IdentityId']
credentials = client.get_credentials_for_identity(IdentityId=_id)
access_key = credentials['Credentials']['AccessKeyId']
secret_key = credentials['Credentials']['SecretKey']
session_token = credentials['Credentials']['SessionToken']
identity_id = credentials['IdentityId']
print ("Access Key: " + access_key + "\n")
print ("Secret Key: " + secret_key + "\n")
print ("Session Token: " + session_token + "\n")
print ("Identity ID: " + identity_id + "\n")
get_pool_credentials(sys.argv[1], sys.argv[2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment