0

I am new to YouTube Analytics API.

Could you please help me to retrieve data from my associated YouTube channel.

I have populated the data using “youtubeAnalytics.reports.query” in the APIs Explorer window.

But when I am trying to use the below HTTP request

https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3D{MY_ASSOCIATED_CHANNEL_ID}&start-date=2016-08-01&end-date=2016-08-31&metrics=views&dimensions=video&filters=video%3D%3D{MY_VIDEO_ID}&max-results=10&sort=-views&key={MY_API_KEY}

It shows an error message “Login Required”

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

Could you please help me to correct my HTTP request to populate the data.

Thanks, Aneesh

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Aneesh
  • 69
  • 1
  • 5

1 Answers1

0

As far as I know most all of the YouTube Analytics API is private data. Being that its private data you need to be authenticated in order to access it.

Your error "Login Required" means exactly that you need to be authenticated to access the data you are requesting. Probably using the scope

https://www.googleapis.com/auth/yt-analytics.readonly

Once you have authenticated your application you can do access_token={Access token gotten from authentication} in order to access that data.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Hi, Thanks for the information, and it is working fine. Now the issue is refreshing the access token . I am using google app script to process the HTTP request. Is there any app script is available to refresh the existing access token. Thanks, Aneesh – Aneesh Sep 21 '16 at 07:16