简体   繁体   中英

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!

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() (ie login) works just fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM