2. Set up GCP services - clarelgibson/tableau-public-autorefresh GitHub Wiki

◀︎ Previous step

This project uses Google Drive to store the data needed for the project and Google Cloud Platform (GCP) for automated authentication (so that when your scripts run themselves on a schedule, they can log in to your Google account without you being physically present). If this is your first time using GCP it can be a little daunting. Following the steps below will get you all set up for this project. If you're interested in learning more about GCP, Google offers a wide range of training materials.

Sign in to Google

Navigate to google.com and sign in to the account you wish to use for this project. I have a Google account that I use solely for data science work and which is not linked to any of my personal emails or files.

Google sign in screen

Go to Google Cloud Platform

Now navigate to Google Cloud Platform Console to enter your GCP console. You should see a screen that looks like the one below. However, if you have ever previously created a project, your screen may look a little different and display the landing page for the last project you accessed.

Google Cloud Platform landing page

Go to IAM and admin

On the left-hand menu sidebar, hover over IAM and admin to open its sub-menu. You may need to click on the Navigation menu icon at the top left of the screen to open the sidebar.

Identity and Access Management (IAM) allows you to authorise who can take action on specific resources, giving you full control and visibility to manage Google Cloud resources centrally.

Google Cloud Platform landing page with IAM and admin button highlighted

Create a project

Click on Create a project to create a new project.

Google Cloud Platform landing page with Create a project button highlighted

Give your project a name that states its purpose. The purpose of this project will be to allow automated authentication with Google Drive, and you will be able to use this Google Cloud project across many of your data analysis projects, so you may wish to choose a name like google-drive-authentication.

The system will suggest a Project ID for your project. You can choose to accept the suggestion or edit it to something more memorable for you. I chose to set the Project ID to be the same as the Project Name. You can leave the Location field set to "No organisation" and click Create.

Google Cloud Platform new project set-up page

Create a service account

Next, you need to create a Service account for this project. Click on Service account under IAM and admin.

Google Cloud Platform landing page with Service account button highlighted

Click on CREATE SERVICE ACCOUNT.

Service account page with Create service account button highlighted

Fill out the service account details. Give the account a descriptive name like gdrive-service-account and a description of what the service account will be used for, e.g. Automated access to Google Drive.

Service account creation page

Click CREATE AND CONTINUE, then grant the service account the role of Owner.

Service account grant access page

At this point you can click on DONE. Click on your newly created service account from the project page. The email you see listed is something you will need later on, so keep a copy of it somewhere.

Service account details on project page

Create a key

From the Service account details page, click on KEYS to create a new key.

Service account details with Keys button highlighted

Click on ADD KEY and Create new key.

Create a new key button

Make sure that the Key type is set to JSON then click CREATE.

Create a private key message box

You will see a message box and the JSON file will download to your computer. Store the file in a secure space, where it will not be uploaded to a public repository on GitHub. You can do this by adding it to your .gitignore file or by making it an environment variable.

Enable Google Drive API

Go back to the main navigation sidebar, hover over APIs and services and then click on Library.

APIs and Services Library button

From the library scroll down or search for Google Drive API and click on it.

Google Drive API button

On the next screen click ENABLE.

Google Drive API Enable button

▶︎ Next step

⚠️ **GitHub.com Fallback** ⚠️