Harshit Anand
Harshit Anand

Reputation: 702

AWS amplify google sigin with react doesn't automatically refresh token after 1 hour?

Using the implicit grant flow (Amplify configured with Auth.oauth.responseType = 'token'), after redirection from Cognito Hosted UI the idToken and accessToken are correctly populated, refreshToken stays empty - as it is supposed to be:

enter image description here

The automatic refresh token will happen if you provided that code snippet on your react app. The library requires in order to refresh the tokens without add refreshHandlers callback. This is what documentation says but it didn't worked.

Can someone help me how to refresh the tokens for user with AWS Amplify?

Upvotes: 6

Views: 1552

Answers (1)

schellack
schellack

Reputation: 10274

There is no refresh token to refresh because you are using the implicit grant type instead of the authorization code grant type. Change the grant type from token to code and then you will see a refresh token in the debug log.

Per the AWS Mobile Blog:

the implicit grant does not generate refresh tokens

Change the auth options that you pass to Amplify.configure to look like this:

Amplify.configure({
  Auth: {
    // other configurations...
    // ...
    oauth: {
      // ...
      responseType = 'code'
    }
    // ...
  }
});

Upvotes: 3

Related Questions