I want to authorize user requests to API via AWS Cognito (Google identity provider). At the moment I can recieve JWT token (id_token and access_token) from aws and authorize requests, but I did it with id_token and not with access_token. But some articles says that using id_token to authorize API request is a bad practice (sending id_token from frontend in headers) and I should use access_token. Is it possible to make same thing with access_token instead of id_token?
import boto3
id_token = get_token_from_headers(headers)
identity_client = boto3.client('cognito-identity')
id_response = identity_client.get_id(
AccountId='account_id',
IdentityPoolId='identity_pool_id',
Logins={
'cognito-idp.us-west-1.amazonaws.com/us-west-1_blabla: id_token'
}
)
response = identity_client.get_credentials_for_identity(
IdentityId=id_response['IdentityId'],
Logins={
'cognito-idp.us-west-1.amazonaws.com/us-west-1_blabla': id_token
})
access_key = response['Credentials']['AccessKeyId']
secret_key = response['Credentials']['SecretKey']
session_key = response['Credentials']['SessionToken']
Looks like it is able to get temporary credentials with access_token from assume_role_with_web_identity link to docs, but the docs says that WebIdentityToken argument for this methods only accepts access_token in cases when as oAuth providers are Amazon and Facebook