To start using the YouTube Data API, you need to create an API key and OAuth credentials to enable the YouTube Data API service. Follow the steps below to set up your working environment.
You need a Google account to access the Google API Console to generate an API key and OAuth credentials. Follow the steps below to set up a project and enable the YouTube Data API for the project:
Select a project in the API Console.
If no project exists, create a new one by clicking the “NEW PROJECT” button and filling the required fields.
You’ll be redirected to the project dashboard once the project has been created. The next step is to enable the YouTube Data API. You can do so by following the steps below:
Go to the Library panel and search for “YouTube Data API v3.”
Select the “YouTube Data API v3” card from the search results.
Click the “Enable” button to ensure that the API is enabled for your project.
Now that you have enabled the API for your project, you’ll now create an API key.
You’ll require an API key to make API requests for the endpoints that don’t require user authorization. For example, to retrieve information about a public YouTube video, you don’t need authorization.
Follow the steps below to create an API key:
Go to the Credentials panel and click the “CREATE CREDENTIALS” button.
Click the “API key” option from the drop-down menu to generate a new API key for your project. A pop-up will appear containing the value of the API key.
In order to make API requests that require user authorization, you need to use a client ID. For example, you’ll need user authorization to retrieve information for a personal YouTube video or to comment on a video, etc.
When creating a client ID for the first time, you’ll be asked to configure your consent screen. Follow the steps below to do so:
Go to the Credentials panel and click the “CONFIGURE CONSENT SCREEN” button.
You’ll be asked to choose the user type for configuring your app. Choose “External” and click the “CREATE” button.
You'll be presented with a form to register your application. On the "OAuth consent screen" section, do the following:
Under the “App information” section, fill in the “App name” and “User support email”.
Under the “Developer contact information” section, add an email address to which you want to get notifications about changes to the project.
Click the “SAVE AND CONTINUE” button.
On the “Scopes” section, just click “SAVE AND CONTINUE” to continue with the setup.
On the “Test users” section, add a test user as follows:
Click the “ADD USERS” button to add a test user.
In the window that appears on the right side, enter the email address of the test user and click the “ADD” button.
Click the “SAVE AND CONTINUE” button to move forward.
In the “Summary” section, you can verify the details of the app. Click the “BACK TO DASHBOARD” button to configure the consent screen.
To create an OAuth 2.0 client ID, follow the steps below:
Go to the Credentials panel and click the “CREATE CREDENTIALS” button.
Click the “OAuth client ID” option from the drop-down menu.
Select “Web application” as the “Application type” of your OAuth 2.0 client and keep the default name for the client.
Additionally, you can add redirect URIs based on your project.
Finally, click the “CREATE” button.
Free Resources