Google Sheet API - get started

Get Started with Google Sheet API | OAuth Authentication Setup | First API call – 2021

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

Hi welcome to my blog post, hope you are doing Good.

Let’s first understand what is a spreadsheet? We all have probably have used a spreadsheet once or 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 Project 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 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 API 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:

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 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 Refesh Token –

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

This I have already covered in step 4 of 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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *