KodiMultimediaOpen Source SoftwareTutorials

How to watch Youtube on Kodi and solve 403 error on Google sign in

Youtube videos, whether these are classical on-demand videos or live-stream videos, can also be watched inside Kodi. The video source plugin "Youtube", an official Kodi plugin, can be used for this purpose.

However Google has restricted non-authenticated access to Youtube videos a while ago. This means: Without authentication, this video plugin will not be able to work. It will fail at the "Sign in" step. The plugin will notify you, that you need to configure API access first.

So does this mean, one needs to enter the personal Google login? Kind of. Basically the login will be based on your own Google login, but unfortunately it's more complex. You will need to create a Google Developer API Key and additional Oauth2 credentials (client key and secret key) in order to log in.

Preparing Google API access

The best description for this can be found on the Personal API Keys wiki page of the Youtube plugin.It explains all the steps below in a video.

First you need to sign in into the Google API console, using your own Google account.

Create a new project. Give that project any name. I simply called it "Kodi".

On the dashboard of this new project, click on [ENABLE APIS AND SERVICES]. This will open an API library. Scroll down (or search) until you find the YouTube Data API v3:

Youtube Data API

Click on YouTube Data API v3 and then enable this API. This will get you back into the dashboard of the GoogleAPI's console from before.

In the left navigation, click on Credentials. Then on top of the page click on the [+CREATE CREDENTIALS] button.

Google API Create Credentials

A drop down menu offers three choices: API key, OAuth client ID and Service account. In order to grant Kodi access to Youtube, an API key and OAuth credentials (client ID and secret) need to be created.

Click on [API key] to create a new API key. The key should be promply generated and shown to you.

Google API Key

Note the yellow/orange warning sign. We'll come back to that later.

Next thing to do is to  configure the OAuth consent screen. This needs to be done before the OAuth 2 credentials (or you will get a message saying this). In the left navigation, click on [OAuth consent screen]. Enter the app name (here I used Kodi) and a support e-mail (your own Google account address) and at the end of the form, click on [Save and Continue].

Now finally OAuth2 credentials can be created. Click on [+CREATE CREDENTIALS] once again, then on [OAuth client ID].

A form will show up, asking your for the application type. For a device such as Kodi select [TVs and Limited Input devices], and give the client a name. I gave it the name "Kodi Office" as I have two Kodi devices in my home.

Create new OAuth client ID in Google API

Click on [CREATE] and you should receive the client id and the client secret immediately:

OAuth client created

Copy the Client ID and the Client Secret, they will be needed in Kodi.

That's it for the API preparation.

Configure Youtube plugin in Kodi

In Kodi, navigate to Addons -> Video add-ons and select the YouTube add-on. Go into [Settings] of this add-on. In the left navigation, select [API] and on the right side select [Enable API configuration page].

This will launch a HTTP listener on the Kodi device, listening on port 50152.

In a browser, enter the following URL: http://KODI-IP-ADDRESS:50152/api where KODI-IP-ADDRESS is of course the ip address of your Kodi device. This will show a form called YouTube Add-on API Configuration:

YouTube add-on API configuration

Enter the API key which you copy from the Credentials overview of the GoogleAPI console.

API Id and API Secret can be found by opening (editing) the OAuth 2 Client ID:

Copy OAuth credentials

Enter Client ID and Client secret into the form fields and click on [Save]

To be save, restart Kodi afterwards.

Signing In with Google account

Launch the Youtube add-on in Kodi and select [Sign In]. The plugin should now use the API credentials in the background and then display a code, which needs to be entered on google.com/device.

YouTube Kodi add-on requires sign-in

You can use a separate device or a computer to do this in a browser. Enter the code, shown in Kodi and click on Next.

Google Connect a device with code

Afterwards, you need to grant access to the device (Kodi) to Youtube, by clicking on Allow. This could look like this window:

Grant YouTube add-on access to Google account

Then the same happens again: Kodi will display another code, which needs once more entered on google.com/device. The second approval should be enough to finally use the Youtube add-on on Kodi.

Second sign-in ends in 403 error

It is possible that you get a 403 error from Google on the second authentication attempts, looking like this:

Authorization Error from Google

In this case you need to re-configure the API key, created in the first step. Remember the yellow/orange warning sign? The 403 error is related to this.

In this case, edit the API key and restrict the API key to a single API. In this case the Youtube API:

Restrict Google API key

Furthermore you might have to change the publishing status of the OAuth consent screen to production. By default the status is set to Testing:

Default publishing status is Testing

Once clicked on [Publish App], the status should change to Production:

OAuth consent screen published

Now proceed with the sign-in procedure on Kodi again.

After you've entered the second code, you should get a different response in browser (Google hasn't verified this app):

Google hasn't verified this app

Click on Advanced and then click on [Go to Kodi (unsafe)] and finally the Youtube add-on is able to sign in and you'll be able to play Youtube videos on Kodi! 

Youtube in Kodi!

This article was first published on claudiokuenzler.com.

Claudio Kuenzler
Claudio has been writing way over 1000 articles on his own blog since 2008 already. He is fascinated by technology, especially Open Source Software. As a Senior Systems Engineer he has seen and solved a lot of problems - and writes about them.

You may also like

Leave a reply

Your email address will not be published. Required fields are marked *

More in:Kodi