-1

I have the following code that runs on google colab. I want to be able to run this code locally but I am constantly running into errors.

# Auth GDrive
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

# Key
downloaded = drive.CreateFile({'id': 'id1'})

# Load Up Python Files
pyDownload = drive.CreateFile({'id': 'id2'})
pyDownload.GetContentFile('file.zip')

consumer_key = ''
username = ''
private_key = downloaded.GetContentString()

Any ideas on how to make it work locally?

K_BAT
  • 1

1 Answers1

0

The Colab auth module referenced in your snippet is only available on Colab backends. It won't work outside of the Colab environment.

In order to authenticate PyDrive locally, you'll need to create an OAuth client app in the Google API console and use the resulting API credentials. The PyDrive docs have some examples here:

https://pythonhosted.org/PyDrive/oauth.html

Bob Smith
  • 36,107
  • 11
  • 98
  • 91