Does anyone have any example or documentation how to connect a Service Account from Google Drive API with pydrive
. I managed to do it with auth2 client.
Asked
Active
Viewed 3,663 times
5
-
Ever figured out how to make this work properly? It seems to work with the method suggested below at first, but then after 1 hour (3600 seconds) the session expires and it fails to renew (for some reason pydrive2 tries to use a different mode, spews "InvalidConfigError" looking for nonexistent file client_secrets.json) – Manchineel Jul 29 '22 at 00:25
1 Answers
4
Apparently this should work, but it does not:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from oauth2client.service_account import ServiceAccountCredentials
gauth = GoogleAuth()
scope = ["https://www.googleapis.com/auth/drive"]
gauth.credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_FILE, scope)
drive = GoogleDrive(gauth)
UPDATE: error was caused by some missing permissions in google IAM.
-
1Ever figured out how to make this work properly? It seems to work at first, but then after 1 hour (3600 seconds) the session expires and it fails to renew (for some reason pydrive2 tries to use a different mode, spews "InvalidConfigError" looking for nonexistent file client_secrets.json) – Manchineel Jul 29 '22 at 00:25