calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.46k stars 235 forks source link

YouTube API change? #792

Closed b4 closed 5 years ago

b4 commented 5 years ago

System Information

Hi,

Any time I try to add a youtube video with a key that previously worked, and no changes aside from updating cytube...every attempt returns Forbidden.

Has there been a change to youtube's API?

I've tried going to the youtube API URL to re-follow the instructions to try and change the key ... except the entire interface has changed drastically. Did the API increment a version again?

I've cleared out and reinstalled all node modules and did the build-server command.

calzoneman commented 5 years ago

Did your server's IP address change? YouTube keys are permissioned by IP which you can whitelist from the API console

On Tue, Jan 22, 2019, 23:59 Madeline Autumn-Rose <notifications@github.com wrote:

System Information

  • Operating System:
  • Node Version: v8.15.0
  • CyTube Version: v3.63.1
  • Error Messages Displayed: Forbidden (when adding youtube video)

Hi,

Any time I try to add a youtube video with a key that previously worked, and no changes aside from updating cytube...every attempt returns Forbidden.

Has there been a change to youtube's API?

I've tried going to the youtube API URL to re-follow the instructions to try and change the key ... except the entire interface has changed drastically. Did the API increment a version again?

I've cleared out and reinstalled all node modules and did the build-server command.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/calzoneman/sync/issues/792, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXiiE_4zPDAEXoEVSyHj6g2NkRbabEVks5vGBZYgaJpZM4aOOnx .

b4 commented 5 years ago

Yes, my IP did change. I didn't know that was a thing. Thanks for the pointer, i'll look that over when i get a chance

b4 commented 5 years ago

I created a completely new project, new API key, and everything (as I can't find the IP restrictions page) and the same issue presents itself. What magical page am I missing?

calzoneman commented 5 years ago

Apparently they don't require you to restrict your API key by IP anymore, although you can still do this and the key shows a warning if you haven't done so.

To register an API key:

  1. Go to https://console.developers.google.com/, create a new "project" (or choose an existing one)
  2. Make sure the YouTube Data v3 API is "enabled" for your project: https://console.developers.google.com/apis/library/youtube.googleapis.com
  3. Go to "Credentials" on the sidebar of https://console.developers.google.com/, click "Create credentials" and choose type "API key"
  4. Optionally restrict the key, or just copy the key.

You can test your key like so:

$ export YOUTUBE_API_KEY="your key here"
$ curl "https://www.googleapis.com/youtube/v3/search?key=$YOUTUBE_API_KEY&part=id&maxResults=1&q=test+video&type=video"
{
 "kind": "youtube#searchListResponse",
 "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/qxXalBgF7OxddF2n1i8bg3At2p8\"",
 "nextPageToken": "CAEQAA",
 "regionCode": "US",
 "pageInfo": {
  "totalResults": 1000000,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/cvEhfQJOem9LxDWKxQPMCN9p7Cs\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "Bey4XXJAqS8"
   }
  }
 ]
}

It may take a few minutes before your key starts working.

b4 commented 5 years ago

Key works fine in curl but not when adding a video via the web...is there a means of enabling further debugging so I can see what is returning Forbidden?

calzoneman commented 5 years ago

Have you double checked that there are no stray spaces or punctuation around the key in config.yaml?

Have you double checked that you restarted the process after changing the config file?

b4 commented 5 years ago

Copy and pasted the key directly from the config file for the curl test.

Looks like one final restart has it all sorted. Restarted earlier but maybe I just didn't wait long enough after key recreation.

b4 commented 5 years ago

Right. this is sorted. closing. thanks for the help.

calzoneman commented 5 years ago

I originally left it open because I think there is still something to be fixed here which is to update the config.template.yaml comments so that it matches what is required today.

Feel free to submit a PR if you'd like to do that.

On Fri, Feb 1, 2019, 14:14 Madeline Autumn-Rose <notifications@github.com wrote:

Closed #792 https://github.com/calzoneman/sync/issues/792.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/calzoneman/sync/issues/792#event-2113372175, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXiiE4QAJee-JLYAuJ_8p6NX4pvn6Efks5vJLw-gaJpZM4aOOnx .

calzoneman commented 5 years ago

Fixed instructions in https://github.com/calzoneman/sync/commit/66d81ffb22ebcb6257bb17d891983cc3bca8165e