Refresh token using react-google-login and django-allauth

Viewed 1114

I'm trying to use Google Login for my web app with a React front-end and Django backend. On the front end, I use react-google-login package to handle all the auth logic. On the backend, I have django-allauth with social login adapter in conjunction with Django Rest Framework (DRF).

Everything is working fine (i.e. I get an access token back and can make API requests to DRF just fine), except for the following:

  • The token is only valid for 1 minute (3599 seconds to be exact - see the image attached)
  • I can't seem to find the refresh token anywhere.

I'm not sure where to look to:

  • Extend the session to longer than 1 minute
  • Refresh so that I can get another access token

One strange thing to note is that when the token expires, refreshing the browser seems to automatically gives me a fresh token and I can make API requests again.

Here's my current react code for this:

<GoogleLogin
    clientId={process.env.REACT_APP_GOOGLE_OAUTH_CLIENT_ID}
    buttonText="Continue with Google"
    onSuccess={handleGoogleOAuthResponse}
    onFailure={handleGoogleOAuthResponse}
    isSignedIn={true}
/>

enter image description here

1 Answers

expires_in=3599 means the token will expire in 1 hour. The time mentioned here is in seconds. 1 minute = 60 seconds. 1 hour = 60 minutes. Also, 1 hour = 3600 seconds.

id_token here is used as refresh token for your system.

Related