Search code examples
google-app-engineoauth-2.0google-oauthgoogle-appsgoogle-apps-marketplace

How to get offline access in google api without prompting the user


I got basic profile info permission from a user through my google app. And now i newly added "access_type=offline" in the api call. It will prompt the user in consent screen like "Have offline access". How do i avoid this screen and get automatically offline access from user without consent screen.

My api call:

https://accounts.google.com/o/oauth2/auth?client_id=CLIENTID&redirect_uri=REDIRECTURI&scope=email+profile+https://www.googleapis.com/auth/drive.readonly&response_type=code&access_type=offline&state=12345678909876543

in the above url i added access_type=offline newly. So it display a consent screen like "Have Offline Access". help me to get offline access from user without prompting the consent screen while user clicks my google app from their account.?

Thanks in advance.


Solution

  • It is not possible to get offline access without user consent.

    But maybe you don't need offline access. When you have an administator install your app through gsuite marketplace, you can use a service account to do stuff in the users drive by impersonating. That way you don't need each user of your domain to give consent.

    Be aware that you cannot use the service account for everything. For instance: you cannot impersonate a user and than call an appscript script.