Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for creating an API key and OAuth credentials #439

Open
tl-pierre opened this issue Apr 2, 2023 · 17 comments
Open

Instructions for creating an API key and OAuth credentials #439

tl-pierre opened this issue Apr 2, 2023 · 17 comments
Labels
bug Something isn't working

Comments

@tl-pierre
Copy link

tl-pierre commented Apr 2, 2023

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 😍

@tl-pierre tl-pierre added the bug Something isn't working label Apr 2, 2023
@slax57
Copy link

slax57 commented Apr 14, 2023

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 #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 #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 😇

@thecyberd3m0n
Copy link

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

@Otiel
Copy link

Otiel commented Apr 30, 2023

Thanks for the detailed guide @slax57! ❤️

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

@DavidFW1960
Copy link

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

@MoojMidge
Copy link
Collaborator

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?

@DavidFW1960
Copy link

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

@MoojMidge
Copy link
Collaborator

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.

@DavidFW1960
Copy link

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

@MoojMidge
Copy link
Collaborator

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.

@DavidFW1960
Copy link

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

@MoojMidge
Copy link
Collaborator

MoojMidge commented Oct 5, 2023

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.

@DavidFW1960
Copy link

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....

@MoojMidge
Copy link
Collaborator

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.

@DavidFW1960
Copy link

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.

@MoojMidge
Copy link
Collaborator

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.

@DavidFW1960
Copy link

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….

@MoojMidge MoojMidge changed the title Wiki API addon tutorial video is down Instructions for creating an API key and OAuth credentials Sep 7, 2024
@cg00001
Copy link

cg00001 commented Sep 16, 2024

1

This is what I did -and worked- when Youtube had a quota frenzy on me last year:
https://console.cloud.google.com/apis/dashboard

  1. Check traffic and quotas clicking on Enabled APIs & services. If your API was left on a build or Youtube is playing dirty is irrelevant. You will change your API and Youtube Kodi addon will work -at least for a while.
  2. Click on Credentials.
  3. Click on CREATE CREDENTIALS.
  4. Click on API key.
    After it's created, click on it, it's suggested to limit it to work only with YouTube Data API v3.
    Make sure to save it, it's the one that will replace the old one in your api_keys.json which is in your /.kodi/userdata/addon_data/plugin.video.youtube/ folder.
    You can save api_keys.json somewhere and once you install/update a build or plain Kodi, just install Youtube addon, and replace it with yours to easily sign in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants