How to Connect Google Drive to Python using PyDrive
The Ultimate PyDrive Tutorial
PyDrive is a high-level Python wrapper for the Google Drive API. It allows you to easily upload, download, and delete files in your Google Drive from a Python script.
In this article we will cover:
- Getting an API key from Google Drive
- Installing PyDrive
- Using PyDrive (authorization, creating files, searching for files, downloading, (un)trashing and deleting, uploading, etc.)
- Using PyDrive in places without a web browser (e.g., Kaggle Kernels)
- Examples of PyDrive in the real world
Feel free to skip to any section!
All the code we develop in this article will be available on my GitHub, here.
Getting Your API Key
First we need to enable the Google Drive API. To do that head over to this link, and click “Enable” (if you’ve already enabled the API for whatever reason, click “Manage”).
Then set your “User Type” as external, here, and click create. Next you’ll need to fill out the OAuth consent screen. All you need to do here is specify an application name.