Error: "message": "Login Required" when use Youtube Analytics API

Kishore picture Kishore · Jan 20, 2016 · Viewed 27.1k times · Source

I am working with youtube api. when I hit this url "https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2015-01-01&end-date=2016-01-31&metrics=likes%2Cdislikes&key={API Key}"

it gives 401

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Login Required",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Login Required"
 }
}

but I hited in the explorer "https://developers.google.com/apis-explorer/?" it working fine.
How do I make the first request work?

Answer

DaImTo picture DaImTo · Jan 20, 2016

In your request you are sending key={your key} for an access token you should be sending access_token={your oauth2 access token}

Note: Key is used for public requests. access token is for authenticated requests.