'AWS boto3 Cognito Invalid Access Token Error
I have a Python lambda function processing an API request from a user to change their password. The API for change_password is as follows
response = client.change_password(
PreviousPassword='string',
ProposedPassword='string',
AccessToken='string'
)
My question is what should I use to populate the AccessToken? I have tried the user's token obtained at login (and passed in the event). I have tried the assumed role's credentials:
session = boto3.Session()
credentials = session.get_credentials()
accessKey = credentials.access_key
Unfortunately neither work. Thanks!
Solution 1:[1]
OK - in order to help anyone else as dumb as me... I was using the Cognito IdToken not the AccessToken (as is clearly stated in the docs - RTFM). Not sure I really understand when to use each one, but using the AccessToken generated by cognito.initiate_auth() (i.e. login) works just fine!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | redPanda |