redPanda
redPanda

Reputation: 797

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!

Upvotes: 1

Views: 814

Answers (1)

redPanda
redPanda

Reputation: 797

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!

Upvotes: 2

Related Questions