简体   繁体   中英

How to get refresh token using amazon cognito in case of Preauthenticated User

My webapp using amazon cognito hosted UI for login page. So after successful login, cognito redirects user to my webapp and my webapp receives jwt token which contains id token, access token, expiration time etc. Now this token has expiration time and I would like to get new id token before my token gets expired to keep user session going.

I have searched on amazon cognito sdk for pre authentication scenario on below url. https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html but it says "The refresh token is defined in the specification, but is not currently implemented to be returned from the Token Endpoint"

Can anyone guide me or give me an example how to do it? Please advise.

You need to set response_type to "code" in the query string parameters of the Cognito hosted form URL, then when your app handles the redirect it should use this code to get the ID, Access and Refresh token from the Cognito Token endpoint.

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