mr. Prophet2
mr. Prophet2

Reputation: 41

When does Refresh Token expires for Google Drive API?

I just Started using Google Drive API using python to download File. I'm seeing it requires authentication for the first time and generates a token.pickle file. From next time onwards we can use this token file for API call.

Note : The file token.pickle stores the user's access and refresh tokens.

What I needed to know is when this token file will expire ? If it expires then how to extend it's validity ?

I've gone through many google documentations but couldn't find anything clear regarding this.

If anyone can suggest me any info on this, that will be most welcomed.

Upvotes: 4

Views: 6944

Answers (2)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116868

Refresh tokens shouldn't expire but they can.

  1. If the user removes your access though their Google account the refresh token will expire
  2. if the refresh token has not been used in six months it will expire.
  3. When you a user authenticates your application you get an access token and refresh token, if they authenticate your application again, you will get another access token and refresh token. You can have up to fifty refresh tokens for a users account and they will all work but after 50 the first one will expire.

Access tokens expire after an hour and you use the refresh token to request a new one.

Update for 2021

A Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days.

Upvotes: 4

Blue Bird
Blue Bird

Reputation: 321

If your app's publishing status is in 'Testing', then the token will last for 2 weeks only.

If its publishing status is 'in Production' then the token has no expiry. However if any sensitive scopes are there and not verified in your app, then the number of users also limited.

These are all tested but seems no official documentation is available yet.

Upvotes: 0

Related Questions