modxevil / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 0 forks source link

YouTube API key with referer not working. #528

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

This is regarding the YouTube Data API v3. Create a github pages site on 
YOURGITHUBPAGESITE.github.io. 
From the Google Developers Console, enable YouTube Data API and create a 
browser key (also tried server key).

Set the accept requests....

Accept requests from these HTTP referrers (web sites) (Optional)
Use asterisks for wildcards. If you leave this blank, requests will be accepted 
from any referrer. Be sure to add referrers before using this key in production.

*.YOURGITHUBPAGESSITE.github.io/* *.googleapis.com/* 
https://www.googleapis.com/youtube/v3/* *.www.googleapis.com/youtube/v3/ 
https://YOURGITHUBPAGESSITE.github.io/* http://YOURGITHUBPAGESSITE.github.io/* 
*.github.com/*  

What is the expected output? What do you see instead?

When you surf to (or call this on the github.io pages site from where it should 
work...) 
https://www.googleapis.com/youtube/v3/videos?part=contentDetails%2C+snippet&id=W
fj4g8zh2gk&fields=items(contentDetails%2Csnippet)&key=AIzaSyCMA_ad2PgYAG5qxWEFvo
8y4EfjB9cGMjw

You see:
{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "ipRefererBlocked",
    "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
    "extendedHelp": "https://console.developers.google.com"
   }
  ],
  "code": 403,
  "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
 }
}

You should see (which is what I see if I use a public api key with no referrers 
which it says not to use in production):
{
 "items": [
  {
   "snippet": {
    "publishedAt": "2010-06-16T22:55:08.000Z",
    "channelId": "UCR4CWnHlNykplffDhjvhcWQ",
    "title": "Like I Used to Do.mp4",
    "description": "Seldom Scene on Song of the Mountains.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/Wfj4g8zh2gk/default.jpg",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/Wfj4g8zh2gk/mqdefault.jpg",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "https://i.ytimg.com/vi/Wfj4g8zh2gk/hqdefault.jpg",
      "width": 480,
      "height": 360
     }
    },
    "channelTitle": "loureidand",
    "tags": [
     "Fred Travers",
     "Dudley Connell",
     "Lou Reid",
     "Ben Eldridge",
     "Ronnie Simpkins",
     "bluegrass",
     "seldom scene"
    ],
    "categoryId": "10",
    "liveBroadcastContent": "none",
    "localized": {
     "title": "Like I Used to Do.mp4",
     "description": "Seldom Scene on Song of the Mountains."
    }
   },
   "contentDetails": {
    "duration": "PT4M16S",
    "dimension": "2d",
    "definition": "sd",
    "caption": "false",
    "licensedContent": false
   }
  }
 ]
}

What is the output of 'gcloud info'?

Please provide any additional information below.

Original issue reported on code.google.com by michaell...@boisestate.edu on 8 Feb 2016 at 7:04

GoogleCodeExporter commented 8 years ago
Thanks for reporting this! This issue tracker is for the Google Cloud SDK, 
which is a specific product separate from other Google APIs.

Please report this issue using one of the methods here to ensure it gets in 
front of the right eyes: https://developers.google.com/youtube/v3/support

Original comment by z...@google.com on 16 Feb 2016 at 11:05