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

403s on any searches (logged in or out) #300

Closed
TheKevJames opened this issue Feb 17, 2020 · 3 comments · Fixed by #301
Closed

403s on any searches (logged in or out) #300

TheKevJames opened this issue Feb 17, 2020 · 3 comments · Fixed by #301

Comments

@TheKevJames
Copy link
Contributor

I haven't used this tool since v3.5.6 and it looks like the auth changed a bit, so please let me know if I'm missing something obvious here -- I read the README section and the original issue, made myself an API key and client ID/secret which are living in ~/.config/youtube-viewer/api.json, then ran into the following 403s both when logged in and out.

The error message seems to be pointing to the > on this line, ie. its the 403 that really matters here (although it'd be great to get a better error message for that case!)

Is there something I'm missing here?

» youtube-viewer --version
YouTube Viewer 3.7.4

» youtube-viewer foo
[403 Forbidden] Error occurred on URL: https://www.googleapis.com/youtube/v3/search?key=[...]&maxResults=20&part=snippet&prettyPrint=false&q=foo&type=video
Use of uninitialized value in numeric gt (>) at /usr/local/Cellar/youtube-viewer/3.7.4/libexec/lib/perl5/WWW/YoutubeViewer/Utils.pm line 224.

[!] No video results!
^C

» youtube-viewer --login

:: Get the authentication code: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=523035435583-42vg8g28hel60d8i7nnitok7lktcu3t7.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/youtube.force-ssl

                            |
... and paste it below.    \|/
                            `
Code: [REDACTED]

Remember me [Y/n]: y

=>> Search for YouTube videos (:h for help)
> foo
[403 Forbidden] Error occurred on URL: https://www.googleapis.com/youtube/v3/search?key=[...]&maxResults=20&part=snippet&prettyPrint=false&q=foo&type=video
Use of uninitialized value in numeric gt (>) at /usr/local/Cellar/youtube-viewer/3.7.4/libexec/lib/perl5/WWW/YoutubeViewer/Utils.pm line 224.

[!] No video results!
^C

» youtube-viewer --logout

=>> Search for YouTube videos (:h for help)
> foo
[403 Forbidden] Error occurred on URL: https://www.googleapis.com/youtube/v3/search?key=[...]&maxResults=20&part=snippet&prettyPrint=false&q=foo&type=video
Use of uninitialized value in numeric gt (>) at /usr/local/Cellar/youtube-viewer/3.7.4/libexec/lib/perl5/WWW/YoutubeViewer/Utils.pm line 224.

[!] No video results!
@TheKevJames
Copy link
Contributor Author

Ah, I submitted this issue too soon:

» mv ~/.config/youtube-viewer/api.json ~/.config/youtube-viewer/api.foo.json
» youtube-viewer foo 

 1. Foo Fighters - The Pretender (by foofightersVEVO) [04:31]
# SNIP

So there's something about that API file breaking normal search, independent of the login cycle. Investigating further...

@TheKevJames
Copy link
Contributor Author

Steps to reproduce seem straightforward for me:

  1. On the Google API creds page, do "Create Credentials > API Key" and leave it unrestricted. Copy it into ~/.config/youtube-viewer/api.json ("key")
  2. On the Youtube API creds page, do "Create Credentials > OAuth client ID", select "Other", and copy 'em both into ~/.config/youtube-viewer/api.json ("client_id" and "client_secret", respectively)
  3. Observe 403s on all usages of youtube-viewer

Running --login after the above does not appear to have an effect.

@TheKevJames
Copy link
Contributor Author

Aha, looks like is is strictly an issue on my side -- the API needs to get manually enabled before the new creds will work for you; clicking on "Enable" on this page did the trick for searching for general results only, ie. youtube-viewer foo but not youtube-viewer -L.

Fixing anything that was tied to my account required re-logging in, but immediately worked the second time.

Will submit a PR to clean up these docs a bit; hopefully no one else gets confused like I did!

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

Successfully merging a pull request may close this issue.

1 participant