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

API Key Input Mangling, Client Secret #108

Closed
aphirst opened this issue Aug 5, 2017 · 10 comments
Closed

API Key Input Mangling, Client Secret #108

aphirst opened this issue Aug 5, 2017 · 10 comments

Comments

@aphirst
Copy link

aphirst commented Aug 5, 2017

Steps to reproduce the problem:

  • Run Kodi 17.3 on LibreELEC 8.0.2 (rPi 3)
  • YouTube Add-On 5.4.1, freshly installed (both of its folders deleted, installed from zip)
  • Enter personal YouTube/Google API Key details
  • Attempt Sign In

What should happen:

  • Sign In successful
  • Key info in settings.xml corresponds to that typed

What happens

  • Error 401 when logging in
  • Client Secret field of settings.xml has a spurious extra character at the start

Sign In does work when manually inputting the details into the file, the problem seems to be when inputting it via the Kodi itself.

This happened to me twice in a row, but I sadly didn't take photographs. If you are unable to reproduce yourself, I can do this again, showing the first few characters of each key on-screen and in the xml file.

If you would like any further info, please don't hesitate to let me know.

@micnorian14
Copy link

micnorian14 commented Aug 14, 2017

Can confirm this is an issue and should affect everyone soon. All was working fine until one day last week I got a "key expired" error. Got sick of fiddling with things so started out fresh - fresh install, new key/api etc. I can setup the app without API and it works fine for a while before the "Daily Quota" BS kicks in. But when I input my API creds and sign in again I get a 401 error inputing the first /activate code.

It would appear something has changed on Google's side of things....

@jdf76
Copy link
Owner

jdf76 commented Aug 14, 2017 via email

@micnorian14
Copy link

micnorian14 commented Aug 14, 2017

@jdf76 Confirmed 5.4.1 last week and 5.4.2 today. I'll try a full reset once more to eliminate anything else. One thing I've noticed is the API Client ID is something like:
123456789-987654321abcdefg.apps.googleusercontent.com
But the app trims it down to:
123456789-987654321abcdefg
I'm sure that's intended but I'm just mentioning it.

In relation to what OP was saying about the API Secret having a special/odd character:
Mine is something like "abc123-" with a noticeable "-" (dash) at the end. No idea if that's intentional or not.

EDIT: Just did a fresh install of the app, input API creds verbatim, and reproduced the same issue. It's clear the app is running into an error with google's API.

Here's some pics if you think I'm crazy: http://imgur.com/a/O0Heh

@micnorian14
Copy link

micnorian14 commented Aug 14, 2017

Logfile is here: http://paste.ubuntu.com/25310399/

The juicy part is here:

------ Window Init (DialogBusy.xml) ------
01:12:30.378 T:1256190880 DEBUG: [plugin.video.youtube] Using API key set: own
01:12:30.504 T:1256190880 DEBUG: [plugin.video.youtube] Starting Kodion framework by bromix...
01:12:30.558 T:1256190880 NOTICE: [plugin.video.youtube] Running: YouTube (5.4.2) on Krypton (Kodi-17.3) with Python 2.7.13
01:12:30.558 T:1256190880 DEBUG: [plugin.video.youtube] Path: "/sign/in/
01:12:30.558 T:1256190880 DEBUG: [plugin.video.youtube] Params: "{}"
01:12:30.596 T:1256190880 DEBUG: [plugin.video.youtube] Sign-in: Dual login required |True|
01:12:30.675 T:1962036176 DEBUG: ------ Window Init (DialogConfirm.xml) ------
01:12:30.675 T:1962036176 INFO: Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY
01:12:31.650 T:1816130464 DEBUG: BUTTON [ 0 ] on "Xbox 360 Wireless Receiver" pressed
01:12:31.650 T:1816130464 DEBUG: FEATURE [ a ] on game.controller.default pressed
01:12:31.798 T:1816130464 DEBUG: BUTTON [ 0 ] on "Xbox 360 Wireless Receiver" released
01:12:31.798 T:1816130464 DEBUG: FEATURE [ a ] on game.controller.default released
01:12:31.924 T:1962036176 DEBUG: ------ Window Deinit (DialogConfirm.xml) ------
01:12:31.972 T:1256190880 DEBUG: [plugin.video.youtube] Selecting YouTube config "All"
01:12:31.973 T:1256190880 DEBUG: [plugin.video.youtube] User is not logged in
01:12:32.765 T:1256190880 DEBUG: DialogProgress::Open called
01:12:32.765 T:1256190880 DEBUG: ------ Window Init (DialogConfirm.xml) ------
01:12:32.765 T:1256190880 INFO: Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY
01:12:44.073 T:1256190880 DEBUG: [plugin.video.youtube] YouTube-TV Login: Access Token |True| Refresh Token |True| Expires |1502691163.99|
01:12:44.098 T:1256190880 DEBUG: [plugin.video.youtube] Selecting YouTube config "All"
01:12:44.099 T:1256190880 DEBUG: [plugin.video.youtube] User is not logged in
01:12:44.418 T:1962036176 DEBUG: ------ Window Deinit (DialogConfirm.xml) ------
01:12:44.624 T:1256190880 ERROR: [plugin.video.youtube] YouTube: LoginException: Login Failed: Code 401
01:12:44.626 T:1962036176 DEBUG: ------ Window Init (DialogAddonSettings.xml) ------
01:12:44.627 T:1962036176 INFO: Loading skin file: DialogAddonSettings.xml, load type: KEEP_IN_MEMORY
01:12:44.660 T:1962036176 DEBUG: ------ Window Init (DialogNotification.xml) ------
01:12:46.657 T:1816130464 DEBUG: BUTTON [ 12 ] on "Xbox 360 Wireless Receiver" pressed

@anxdpanic
Copy link
Collaborator

I've been unable to reproduce this and the logs don't really have much information in that area.
There is only one place that the add-on does a simple strip() to remove whitespace but this should not mangle the string as described. (.apps.googleusercontent.com is also intentionally removed)
I've made a PR changing strip() to an alternate method, would appreciate if either of you can test and confirm if the changes resolve it for you since you are able to reproduce the behaviour.

The PR is #113 , the specific changes are in commit 7a41126
Thanks

@jonathansd1
Copy link

I can confirm this is happening to me.

I recently decided I needed to use my own API keys. Went thru the setup, and when I try to log back in I get this exception. Search appears to work fine, so I know my keys are good. Currently running v5.4.5 of the add-on with Kodi Krypton (LibreElec)

@anxdpanic
Copy link
Collaborator

Still unable to reproduce, added extra checks to try to catch any mangling that may be happening.
064a66a

@demonicdragon
Copy link

demonicdragon commented Oct 1, 2017

Getting same login issue. Personal API seems to be working when searching, and when it is set to that I cannot login. Using youtube.com/activate . 'Youtube LoginExeption Error Code: 401'. The code is accepted on youtube/activate and the issue only occurs when trying to login.

On a side note, how do you login with settings.xml? I havent quite worked out where to put my credentials there yet.

@micnorian14
Copy link

[Bingo:] (https://stackoverflow.com/questions/27483674/youtube-api-v3-shows-access-not-configured)

You need to delete the current client key, disable the YT data API, re-enable it, then create a new client key. Confirmed working meow. Not sure what made it stop one day - methinks YT stopped/started my API and that invalidated my key. Confirmed is working fine. Meow.

@anxdpanic
Copy link
Collaborator

Key stripping methods have been changed, error messages in this area are improved, and api keys can be edited from web browser in coming v6

if when signing in you get -- invalid_client : oauth client not found -- the client id is incorrect.
if when signing in you get -- invalid_client : unauthorized -- the client secret is incorrect.

Please re-open if still having this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants