GoogleDrive 7 days refresh token

Viewed 268

As documentation explains google drive refresh tokens expire after 7 days in "test" apps.

As I indeed is it necessary to publish the app to have a persistent token.

However in the documentation verification requirments explain that the use I'm doing could be considered an exception that does not need to be published/verified.

In fact, my need is to connect to my personal google drive to list folders and files on my website. Just form me and my webserver, anyway 1 user.

How to go ahead with a persistent token?

#UPDATE

Currently, my project is stuck. It seems to be moved in production but there is more action I should do. It asks me to "Comply with domain verification requirements Ensure your application's domains have completed the Search Console verification process". The domain is fully verified in the search console but I still have this message and tokens keep valid for 7days only. enter image description here

2 Answers

Verification status and publication status are two different things.

You can only have a refresh token that is valid for longer then seven days if your application has been set to production.

This does not mean that the application needs to be verified.

enter image description here

However some apis do limit what you can do without being verified. For example you cant upload public youtube videos with the YouTube api until the application is verified.

If you want to have more then 100 users then your application will also need to be verified.

service account

If your connecting to your personal drive account you should consider using a service account rather than using Oauth2.

It seems I find the solution! It is not up to consent screen verification but it is up to scopes. I just reviewed the code to be sure to use just scopes that do not require verification (for example, moved from googleapis.com/auth/drive.readonly to googleapis.com/auth/drive.file). I do the same on the consent screen setup and now my refresh tokens are alive after 7 days.

Related