How to Get a YouTube Data API Key and OAuth Credentials
Set up a Google Cloud project, enable the YouTube Data API v3, and create the OAuth client every automation in this series depends on.
Almost every YouTube automation that touches your own channel (uploading videos, editing titles, posting comments, pulling analytics) runs through the YouTube Data API v3, and that API needs an OAuth client tied to a Google Cloud project. This guide walks through that one-time setup so the rest of the integrations in this category just work.
What you need
- A Google account that owns or manages the YouTube channel
- A web browser (everything here is point and click in the cloud console)
- About 10 minutes for the one-time setup
Step 1: Create a Google Cloud project
Open console.cloud.google.com, click the project dropdown in the top bar, then New Project. Give it a name like youtube-automation and create it. Wait for the notification that the project is ready, then make sure it is selected in the top bar.
Step 2: Enable the YouTube Data API v3
From the left menu choose APIs & Services, then Library. Search for YouTube Data API v3, open it, and click Enable. The API will not respond to any of your requests until this is switched on for the project.
Step 3: Configure the OAuth consent screen
Go to APIs & Services, then OAuth consent screen. Pick External, fill in an app name and your email, and add yourself as a Test user. While the app is in Testing mode only the test users you list can authorize it, which is exactly what you want for a personal automation.
Step 4: Create OAuth client credentials
Open APIs & Services, then Credentials, click Create Credentials, and choose OAuth client ID. For a script running on your own machine choose Desktop app. Download the resulting JSON file and keep it private, it is the key to your channel.
Step 5: Verify the file
The downloaded file is usually named something like client_secret_xxxx.json. Rename it to client_secret.json and place it in your project folder. A quick peek confirms it has the fields scripts expect.
{
"installed": {
"client_id": "4812....apps.googleusercontent.com",
"project_id": "youtube-automation-481203",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"client_secret": "GOCSPX-....",
"redirect_uris": ["http://localhost"]
}
}Result
You now have an enabled YouTube Data API v3 and a client_secret.json holding your OAuth client. Every later guide that says assume you have your OAuth credentials is pointing back to this file.
Watch related tutorials
9:47
6:41
12:38
12:00
10:00
12:00