Skip to content

Instantly share code, notes, and snippets.

@leingang
Last active March 12, 2024 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leingang/229ed6b26c4ff4c2e1555217900f162e to your computer and use it in GitHub Desktop.
Save leingang/229ed6b26c4ff4c2e1555217900f162e to your computer and use it in GitHub Desktop.
Allow a Google Colaboratory Jupyter Notebook to access Google Drive files
from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment