1

I have this code:

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import time
gauth = GoogleAuth()
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)

# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents"}).GetList()
for file1 in file_list:
print 'title: %s, id: %s' % (file1['title'], file1['id'])
time.sleep(1)

However, each time I want to run it, it opens my browser and asks for permission to access google drive. How to bypass it? I mean at least ask once, then save the "permission" and don't ask again or (which would be best) silently accept the permission in the background without my decision. I have downloaded client_secrets.json which is used for passing the authorization details.

What if I wanted to release my application? I mean I had to generate + download the client_secrets.json in order to make it work. I guess my users wouldn't wanto to do so. Is there any better, more convenient way?

I would also appreciate a tutorial-for-dummies about using Google Drive API because it's hard for me to understand it reading the documentation alone.

Zwierzak
  • 666
  • 1
  • 11
  • 31
  • If you want to access users data without any manual authorization from them, use service account. Here is the link for the detail description https://developers.google.com/drive/web/delegation.You can check the code sample in the link. – SGC Jan 02 '15 at 19:02
  • I think the service account is seperate from MyDrive and cannot be accessed via the web interface if this is important. – phobic Jan 07 '15 at 19:17
  • So what is the best way to access Google Drive in the fastest way and least work-demanding from user? – Zwierzak Jan 08 '15 at 19:45

1 Answers1

0

pydrive2 has done a fabulous job of automating the authentication file via settings.yaml file. Use the below package if you are experiencing the above problem

https://docs.iterative.ai/PyDrive2/