Set up YouTube OAuth client ID and secret

A guide on how to add YouTube Data API v3 to a Google Cloud Platform project and generate OAuth credentials to use in WordPress plugin YouTubeHub.

1. Create a new project

1.1 Begin by visiting https://console.cloud.google.com.

Step 1 - Google cloud console welcome screen

1.2 After clicking “Select a project“, into the modal window click on “NEW PROJECT” to begin creating your new project.

Step 2 - Create a new project

1.3 Choose a name for your project and click “Create”.

Step 3 - Enter project name

1.4 Wait until the project is created (will take a few seconds) and when done open the newly created project by clicking in “Notifications” area.

Step 4 - Open the project

2. Enable YouTube data API for your project

2.1 After opening the project, scroll down in project Dashboard until you see the “Getting Started” panel. In it, click “Explore and enable APIs“.

Step 5 - Enable YouTube Data API

2.2 In API explore screen, click on “ENABLE APIS AND SERVICES“.

Step 6 - Open APIs screen

2.3 Insert into the search field “YouTube data API“.

Step 7 - Search YouTube Data API

2.4 Click on “YouTube Data API v3” in search results.

Step 8 - Open YouTube Data API

2.5 In API screen, click “Enable” to enable this API for your project.

Step 9 - Enable YouTube Data API

3. Generate OAuth credentials

3.1 In left-side menu of your API click on “Credentials“.

Step 10 - Open Credentials screen

3.2 Click “CREATE CREDENTIALS” and into the menu that opens click on “OAuth client ID“.

Step 11 - Open OAuth credentials screen

3.3 In screen for creating OAuth client ID you will notice that everything is frozen and you are required to configure consent screen. Click on “Configure consent screen“.

Step 12 - Open configure consent screen

3.4 In Consent screen configuration enter a name for your application in field “Application name” and save the settings.

Step 13 - Configure consent screen

3.5 After creating the consent screen click on “Credentials” in left menu and click “Create credentials” in page. This will open a menu, choose “OAuth client ID“.

Step 14 - Open OAuth create credentials screen

3.6 Go to your website and copy the return URL for OAuth. The return URL should be the address to your WP admin screen (ie. https://my-website.com/wp-admin).

Step 15 - Copy redirect URL from plugin

3.7 Paste the return URL in field “Authorized redirect URIs” in OAuth client ID screen. You will notice and error that asks you to add the domain to the authorized domain list. Click the link for the authorized domain link.

Step 16 - Edit consent screen to add domain

3.8 This will take you back to the consent screen settings. In field “Authorized domains” add the domain name from your return URL (ie. my0website.com) and save the settings.

Step 17 - Add authorized domain name

3.9 Do step 3.5 again to open the OAuth client ID screen. In field “Authorized redirect URIs” enter the URL you got from your website on step 3.6 and save the settings.

Step 18 - Add return URL to OAuth

3.10 Copy the client ID and client secret and paste them in your website into fields “Client ID” and “Client secret” in plugin Settings page, tab “API & License”.

Step 19 - Copy credentials

Watch video tutorial

[cvwp_video_position]

Set YouTube server key

After successfully , the next step is to set up the access keys that will allow you to query YouTube.

Before being able to use the plugin you will need to enter at least the YouTube API Server Key that will allow you to use the plugin and import your YouTube videos into WordPress. This can be achieved from Google Console.

To generate the keys, please follow these steps:

Create a new project

Navigate to Google Console and create a new project.

Create new youtube project

Enable API

After you successfully create the project you will be required to enable APIs for this new project. Look into the list of APIs for “YouTube Data API” and click it.

Select YouTube data api

Enable YouTube API

Into the next screen you will see the options for YouTube Data API; make sure you click “Enable” to enable the API for the current project.

Enable YouTube data api

Create credentials

Once enabled, you will be required to create credentials for the current project.

Begin creating credentials

After clicking “Create credentials” you will be presented with a new screen where you will be asked for more details. Make sure that you answer question “Where will you be calling the API from?” with “Web server” and that under “What data will you be accessing?” you choose Public data.

Create youtube project credentials

Get server key

Once completed the previous steps you will be presented with an API key that you will have to copy into the plugin’s Settings page.

Get project api key

Enter API key in plugin settings

Finally, with a valid API key you can now query YouTube API. Last thing left to do is to enter the key into the plugin settings.

Enter YouTube API key in plugin settings