plugin.video.youtube icon indicating copy to clipboard operation
plugin.video.youtube copied to clipboard

Instructions for creating an API key and OAuth credentials

Open tl-pierre opened this issue 1 year ago • 17 comments

Hi, On the Personal API Keys wiki page , the tutorial video for generating API keys is down : "This video has been removed for violating YouTube's Terms of Service" Video URL : https://www.youtube.com/watch?v=4iFaY8IpTeI Currently, there is no other explanation than this video tutorial in the wiki unfortunately.

Thank you for this amazing Kodi plugin :heart_eyes:

tl-pierre avatar Apr 02 '23 15:04 tl-pierre

Here are my 2 cents for this issue.

I found this great video explaining the process, unfortunately it's in French 😁 . I figured it might be useful to some, though, so here it is:

>>> https://www.youtube.com/watch?v=kKMFH5SwyNw <<<

As a complement, here is a small written tutorial with the steps.

API Key Creation

  1. Go to https://console.developers.google.com/ and create a new project

Capture

  1. Click on Activate APIs and Services

Capture2

  1. Activate Youtube Data API v3

Capture3

  1. Go to the Credentials section and click Create new credentials

  2. Create a new credential of type API Key. Choose a name, and leave the restriction choices to No restriction

Capture4

  1. Create a new credential of type OAuth client Id

Capture5

  1. Choose External user type

Capture6

  1. Choose any name for the App. Select your email address in the list. Leave all the other options to the default.

Capture7

  1. Create a new credential of type OAuth client Id, again

Capture5

  1. Choose TV input devices and limited as application type, and leave the client name to default

Capture8

  1. Go to the OAuth consent screen section, and click the Publish button to publish you app

172390662-ba4c2e93-6b19-4353-a485-4cc7fd6ab8f6

Alternatively you can add your Account as a Test User, thereby allowing access. By default nobody (not even the account owning the project) has access.

198346405-9c4328a9-7b35-450e-87cd-eb5a09eeefa9

Kudos to https://github.com/anxdpanic/plugin.video.youtube/issues/312 for this method

  1. Back to the Credentials page, you should now have access to all 3 required keys

Capture9

  1. To get the Client secret, you need to edit the OAuth credential. This should open a popper window including the secret.

Capture10

Configure the Add-on

Follow the instructions in the wiki section: https://github.com/anxdpanic/plugin.video.youtube/wiki/Personal-API-Keys#configure-the-add-on

Sign In

During the add-on Sign in process you'll be asked to Connect a device twice.

The second time you Connect a device, you will be prompted with:

This app isn't verified
This app hasn't been verified by Google yet. Only proceed if you know and trust the developer.

From there clicking Advanced and Go to <your project name> (unsafe) allows you to complete the process.

Capture11

This should be it! 🎉 🎉 🎉

Additional notes

I have noticed that I had to run the whole Sign In process a second time after I exited Kodi and started it back again, i.e. perform the Connect a device action 4 times total.

(this may be related to https://github.com/anxdpanic/plugin.video.youtube/issues/388)

But the good new is, after all this, Kodi now finally remembers my account each time I start it up 🎉 🎉 🎉

I hope this little guide will be helpful to some of you, and why not, could help updating the wiki 😇

slax57 avatar Apr 14 '23 21:04 slax57

just reupload it to other service. Vimeo, Odysee or other

thecyberd3m0n avatar Apr 27 '23 07:04 thecyberd3m0n

Thanks for the detailed guide @slax57! ❤️

I also found this guide helpful for those looking for english screenshots.

Otiel avatar Apr 30 '23 09:04 Otiel

Is there any fix to make this work if you have 2 factor authentication enabled on the account?

DavidFW1960 avatar Oct 04 '23 23:10 DavidFW1960

What doesn't work when you have 2FA enabled?

You need to authenticate account access via a browser to grant Kodi the OAuth access token, and it is only when you login in the browser that you would need to provide the details for the 2FA.

Unless something has changed?

MoojMidge avatar Oct 05 '23 00:10 MoojMidge

What doesn't work when you have 2FA enabled?

You need to authenticate account access via a browser to grant Kodi the OAuth access token, and it is only when you login in the browser that you would need to provide the details for the 2FA.

Unless something has changed?

I am getting a 400 invalid_token error

DavidFW1960 avatar Oct 05 '23 00:10 DavidFW1960

The error is fairly self explanatory - it means that the token you are using is not valid.

This usually will happen when you created the wrong type of token, or are using an old token that is no longer valid that causes the revoke endpoint to return this error when trying to refresh the access token.

This is just a guess because you are not really providing any useful details to diagnose what the problem could be.

You should create a new project/API key with the proper scope, and create new credentials. Enter the new API key details into the addon settings and try signing in again.

If you are still having the same problem create a new issue with full details and a debug log.

MoojMidge avatar Oct 05 '23 01:10 MoojMidge

I reset every page of the addon settings to default and still same error. My token is years old. I will try and create new credentials and try again

DavidFW1960 avatar Oct 05 '23 01:10 DavidFW1960

My token is years old.

Yeah that is the likely cause, they can be revoked due to lack of use, change in scope, on Google's whim, etc.

Just to be sure, make a new API key as well, not just new credentials for an old key.

MoojMidge avatar Oct 05 '23 01:10 MoojMidge

ok I redid the auth and had to log in twice. Seemingly successful. But I get:

error <general>: [plugin.video.youtube] Error reason: |quotaExceeded| with message: |The request cannot be completed because you have exceeded your quota.|```
Hard to see how that's possible given I only just got it auth'ed
I also get list for my Subscriptions.
Here is my log
https://1drv.ms/t/s!An_0ZtrQyrRIhMI_aOKx5ldky-PyGA?e=axfKnn

DavidFW1960 avatar Oct 05 '23 02:10 DavidFW1960

The log is a little strange. You only seem to have logged out and logged back in 7 minutes before closing Kodi, but the quota exceeded errors were occuring well before that.

It almost sounds like your API key has been disabled, but you didn't create a new API key, just a new valid OAuth credential for the existing disabled API key, which is why you are no longer getting the invalid_token_error but the quotaExceeded error instead.

It is not uncommon for this to occur which is why I recommended creating a new API key, not just a new OAuth credential.

ok I redid the auth and had to log in twice

If you are absolutely sure you created a new API key before this, then one thing to check is to go to https://console.cloud.google.com/apis/api/youtube.googleapis.com/quotas and check what your quota allocaton and usage actually is. You should see something like the table below:

image

In some instances a newly created API key may have close to 100% of the daily quota allowance already used, which resets after a period of time (at most one day). Alternatively if you have a disabled API key, you will see that your quote limit is set to zero, and your only option is to create a new API key.

Edit: Also update the addon from here: https://github.com/anxdpanic/plugin.video.youtube/releases/latest v7.0.1 likely won't work even if you do resolve the API key and OAuth login issue. Newer versions may not have those issues at all.

MoojMidge avatar Oct 05 '23 10:10 MoojMidge

Quota is 0. I did create a new API. I updated yesterday to the new version as well. I'm going to try making a new project etc again....

DavidFW1960 avatar Oct 06 '23 03:10 DavidFW1960

Hmm that sucks. It happens sometimes for seemingly no reason, and worst of all there is no advance warning either.

I'm going to try making a new project etc again....

Yeah unfortunately creating a new API key is your only option, and creating a new project is probably a good idea too.

MoojMidge avatar Oct 06 '23 03:10 MoojMidge

I DID create a new API key yesterday as you suggested and today I did the new project and I have a 10000 quota and it's working. Finally. Big thanks for this addon and all your help.

DavidFW1960 avatar Oct 06 '23 03:10 DavidFW1960

I DID create a new API key yesterday

I'll admit I was suspicious because the process is not straightforward and it is easy to not know the reason/significance of each step, but I do believe you (at least now 🙂).

Why it happens, even for a new API key, is something only Google can answer, but it's good you got it working despite the hassle.

MoojMidge avatar Oct 06 '23 04:10 MoojMidge

Yeah i had it working years ago before I switched to using 2FA and it hasn't worked since. It was on the backburner but made it to the front now….

DavidFW1960 avatar Oct 06 '23 04:10 DavidFW1960