Google APIs#

Google developer account#

First, you need to create an account: Google developers

Google APIs Explorer#

The Google APIs Explorer is a tool available on most REST API reference documentation pages that lets you try Google API methods without writing code:

We will use Google’s Drive API v3 as an example.

Google Drive API v3#

We want to create a Python command-line application that makes requests to the Drive API by using OAuth 2.0 for authorization.

Set up Anaconda environment#

First we need to setup a new Anaconda environment where we will use pip to install packages (not conda):

conda create -n drive python=3.9 pip 

Install the Google client library#

Activate your environment:

conda activate drive

Install some libraries for Python:

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib googleapiclient pandas

Python quickstart#

Next, go to the Python quickstart and complete the instructions for step 1, 3, 4 and 5:

  1. Set up your environment (choose user type external)

  2. Install the client library (we already completed this step)

  3. Set up the sample.

  4. Run the sample.

Important note:

Warning

Since our app’s publishing status is in ‘Testing’, the token will last for 2 weeks only. This means after two weeks, you have to delete the file token.jsonand run this script again, to generate a new token.