Create OAuth tokens in Google Cloud to interact with the Youtube Data API

Before we start interacting with Google services through their API, e.g. Update a YouTube video's title, we first need to generate our OAuth tokens in Google Cloud.

Head over to Google Cloud Console to get started. You may need to sign in. You should eventually land on this page.

Google Cloud Console

Once you arrive there, click on Select a project and then New Project.

Select a project

Give your project a name and assign a location. I have left it as No organization, then click Create

Give the project a name

You'll be taken to the following screen. Click on Enabled APIs & Services under APIs & Services`.

Enable APIs

It will bring you to the following page. On that page, click on Enable APIs and Services

Enable the API

From there, let's search for YouTube Data API v3. Click on that when it is displayed in the results.

Search to the Youtube V2 API

Click Enable.

Click Enable

You will be brought to the YouTube Data API v3 homepage. The API has been enabled but we also need to create our credentials i.e. The OAuth Tokens. Click on Create Credentials.

Create credentials

There is a number of sections we need to go through to create our credentials. First, let set the data that we want to access as User data. If it was public data, then we would simply need an API key.

After that, fill in your details under the OAuth Consent Screen.

User Data select

Then we have to add our scopes. This is the section where we tell Google what sections of the API we want to use. Click on Add or Remove Scopes, and scroll across to the two that are selected in the image below. Select them.

Scopes to select

Next, we need to fill the section under OAuth Client ID. Let's select Web Application for our application type, give our app a Name, set our Authorized JavaScript Origins, basically where our requests are coming from and our Authorized Redirect URIs.

OAuth Client ID

We can set the redirect to simply http://localhost:3000/callback. We can then click Create and it will go ahead and create our credentials.

Set the redirect uri and create tokens

It will give you your Client ID, you will have to go ahead and click Download, which will be a JSON object with all your tokens, including your Client secret.

Your OAuth tokens

Finally, we need to add a test user. Back in Google Cloud, click on the OAuth consent, then scroll down to Test User and click Add Users, and add in the email address of your gmail account.

My project-1 (17).png

And that is it! You have created your OAuth Tokens, in Google Cloud for the YouTube Data API.


Image of the Author, Ryan Carmody

About the Author

Open for work

Hi, I'm Ryan from Adelaide, South Australia.

I'm a web developer and computer science tutor. I also rock climb, play wheelchair basketball and brew beer.

Check out some of the games I made

WhereTaken

WhereTaken

Guess the country from a photo.

Retro Snake Game

Retro Snake

Eat the food but don’t hit the walls or your own body!

Retro Worldle

Worldle

Replica of the original but with extra features! Guess countries, flags and capitals.