How To Easily Setup A Google Cloud Project With APIs

James Phoenix
James Phoenix

Learning Outcomes

  • To learn the appropriate steps for setting up a Google Cloud Platform project.
  • To learn how to activate specific APIs which can then be accessed via a Service Account.
  • To learn the importance of hiding your .json service account keys from the internet.

This will be a short guide on how you can get started as quickly as possible using Google Cloud Platform with some of Google’s APIs.

Step 1 – Setup A Google Cloud Platform Account

Firstly you will need to correctly register for a Google Cloud Platform account, you’ll likely be able to use your existing Google account.

Step 2 – Activate Billing

After successfully registering for a trial account you will be entitled to ~$300 free credits that you can spend within the Google Cloud Platform (GCP). However I’d recommend taking the time now to setup billing by adding a valid credit / debit card.

You can create a Billing Account here and its worthing remembering that one billing account can be used across multiple GCP projects.

Step 3 – Create A Google Cloud Platform Project

Similarly to Google Ads campaigns, there is a hierarchy to how your Google Cloud Account is structured:

Therefore whenever you create a new project, you will need to perform the following:

  • Link your active billing account to the project.
  • Activate the relevant resources (BigQuery, App Engine, Cloud Storage) etc.
  • Turn on the relevant APIs (Google Search Console, Google Analytics) etc.

Step 4 – Create A New GCP Project

You can create a new google cloud project here or alternatively navigate to it within the UI, then click Create Project in the top right corner.

For this tutorial we’ll be creating a new project called Google Sheets API:

Step 5 – Select The Newly Created Google Cloud Project

When adding resources and API’s its vital that you double check to make sure that you’ve selected the correct GCP project.

Unleash Your Potential with AI-Powered Prompt Engineering!

Dive into our comprehensive Udemy course and learn to craft compelling, AI-optimized prompts. Boost your skills and open up new possibilities with ChatGPT and Prompt Engineering.

Embark on Your AI Journey Now!

Step 6 – Turn On The Relevant Resources And API’s For Your Project

As we’ll be using Google Sheets within the next lesson, let’s navigate to the API section and turn on that specific API for this new project.

Step 7 – Authentication With A Service Account

Now that we’ve got the google sheets API turned on, let’s create a service account so that you can programmatically access the resources of your google cloud project.

Create A Service Account

Name Your Service Account

Give Your Service Account Ownership + Programmatic Access

In the example below, I have given my service account admin level access to Google Cloud Functions:

Create a JSON Key

Creating a .json key will allow you to easily interact with your Google Cloud Project using Python. So let’s create and download the .json file:

Okay great so you should have just downloaded a .json service_account key!

If you’re following along from the Python For SEO Course, please can you do the following so that the next tutorials will work:

  • Rename your some_name.json key to service_account.json
  • Move the .json key into the root directory of this folder: 5_google_sheets_with_pandas

Protip: You must keep your .json key safe and away from the internet. It gives anyone that accesses complete control over that Google Cloud Project.

If you have forked my Github repository then please create a .gitignore file and remove the service-account.json key from your own repository!

Alternatively, please keep the .json key outside of the repository and reference it throughout the course. (This is only a problem for forked/cloned Github repos and if you are just git pulling but not git pushing then there is nothing to worry about here).

Now that we’ve got a .json key with the google sheets api activated we can now move on to reading and writing data from a live google sheet, see you in the next episode!

TaggedPython For SEO

More Stories

Cover Image for Soft Skills for Programmers: Why They Matter and How to Develop Them

Soft Skills for Programmers: Why They Matter and How to Develop Them

Overview You need a variety of soft skills in addition to technical skills to succeed in the technology sector. Soft skills are used by software professionals to collaborate with their peers effectively and profitably. Finding out more about soft skills and how they are used in the workplace will help you get ready for the job if you are interested in a…

James Phoenix
James Phoenix
Cover Image for What Are Webhooks? And How Do They Relate to Data Engineering?

What Are Webhooks? And How Do They Relate to Data Engineering?

Webhooks are a simple and powerful method for receiving real-time notifications when certain events occur. They enable a whole host of automated and interconnected applications. Broadly speaking, your apps can communicate via two main ways: polling and webhooks.  Polling is like going to a shop and asking for pizza – you have to ask whenever you want it. Webhooks are almost the…

James Phoenix
James Phoenix