How to read files from Google drive with Python with PyDrive


If you need to read files from Google drive with your Python script, you can easily do so using PyDrive2 module.

pip install PyDrive2

However before using it, you have to authenticate with Google OAuth. Go here and create new credentials:

create google oauth credentials

Then it will give you an option to download client_secrets.json (“Download JSON” link from main UI page), do that and place the file in your root project directory. Now you are ready to connect:

from pydrive2.auth import GoogleAuth
from import GoogleDrive

gauth = GoogleAuth()

drive = GoogleDrive(gauth)