Google Sheet API - get started

Get started with Google Sheet API – OAuth Authentication Setup and First API call

How to Enable Sheet API and generate credentials using the Google Console Project?

Hi, welcome to my blog post, hope you are doing Good. Thank you so much for stopping by. Today we are going to set up a Google developer account to use Google Sheet API, create an app or project in the Google Console, enable Google Sheet API, and eventually make our first Google Sheet API call using python. In short, we will see how to set up Google Sheet API.

Let’s first understand what is a spreadsheet? We all have probably used a spreadsheet once or are at least aware of what the spreadsheet looks like. isn’t it.

What is Spreadsheet?

A spreadsheet is a computer application in tabular form for the organization, analysis, and storage of data.

What is Google Sheet?

Now it’s gonna be easy to understand Google Sheets – is nothing but a spreadsheet program included as part of the web-based Google Docs Editors suite offered by Google.

What is Google Sheet API?

A software intermediary provided by google to Read Data, Write Data, Build pivot tables, Apply formulas, format data, and many more in Sheets. This software intermediary (i.e API acronym for Application Programming Interface) lets developers programmatically do all the above mention tasks in Google Sheet.

Google Sheet API - get started

What you are going to get from this article?

  1. You will learn to create projects in Google Console.
  2. You will know to enable API according to your need.
  3. You will learn ways to generate tokens and credentials.
  4. You will have python code to authenticate and make the first API call.

Let’s get started

1. Enable Google Sheet API

To access Google sheet through API calls you need to turn on Sheet API first. In order to do that go to Google Console, create an app or select an app (If you already have a project/application created in google console).

Are you finding it difficult and confusing to create a project in google console? Don’t worry we got you covered – here’s a Detail Guide to Create Google Console Projects.

a. Select Google Console Project –

As you can see from the image below I have selected “My Project” named application/project. That’s a default project created under google console.

b. Search and Enable Google Sheet API

To enable API, confirm you are in the “Dashboard” view and look out for the “ENABLE APIS and SERVICES” button and click on it. Hope you find it soon!

We need two APIs here Google Sheet API and Google Drive API.

First look for Google Sheet API through a bunch of Google’s APIs. The shortest and fastest way is to search for Sheet API. It will look something like the screengrab.

Click on it and enable the API for your project by clicking on the “ENABLE” button.

Second search for Google Drive API. It will look something like the screengrab below.

Click on it and enable the API for your project by clicking on the “ENABLE” button.

2. Generating Credentials for Google Console Project

After you have an Enable API for your project it’s time to generate credentials for your project so that you can use it from the application you are building.

Click on “Credential” as highlighted in the below image.

You should see a few sections like API keys and OAuth 2.0 Client IDs. These are the ways to authenticate your application to Google API.

a. Obtain OAuth 2.0 credentials from the Google API Console

Here we are going to opt OAuth 2.0 protocol for authentication and authorization. Google supports common OAuth 2.0 scenarios such as those for web server, client-side, installed, and limited-input device applications.

To obtain OAuth 2.0 credentials such as a client ID and client secret that are known to both Google and your application.

Click on “CREATE CREDENTIALS” and select “OAuth client ID” from the dropdown.

If you are asked to configure a consent screen and don’t know what to do. I suggest referring to the Google Console Setup Guide (NOTE: you can directly jump to step 3 of that guide).

In step 3 of the above guide, you will be able to complete the consent screen and will land up having a client Id and client secret.

b. Obtain an Access Token and Refresh Token –

Now comes the most important step, generating the access token and refresh token for OAuth verification. 

This I have already covered in step 4 of the Google Console Setup Guide (NOTE: There are 2 ways mentioned there, you can choose whichever suits you best and meets your requirement).

Congratulation! you have successfully set up and got all the credentials needed to authenticate your application on behalf of the user so that you can use Sheet API to read or add data. Hope I have made the entire process of Getting Started with Google Sheet API simple enough.

Since you have all credentials to get started and build your application or integrate Google Sheet with your application. Here’s a guide to help you out with Python Code to read data from Google Sheet using Google Sheet API.

Hope I was able to solve the problem. If you like this article and think it was easy to understand do share it with your friends and connection. Thank you! see you soon.

If you have any questions or comments feel free to reach me at.

Checkout out my other API Integration and Coding Solution Guide