0

I am trying to get youtube video views by date range and it is working fine with oAuth. But I am using cron script to collect those data through service account, when I try to execute the script it says:

Error calling GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUC88Bq63MDJi9szYPEGfv7YA&start-date=2014-02-01&end-date=2016-06-29&metrics=views:
(400) Invalid query. Query did not conform to the expectations".

Could you please help me anyone to resolve this issue. Thanks in advance.

Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
  • Questions seeking debugging help (**"why isn't this code working?"**) must include *the desired behavior*, *a specific problem or error* and *the shortest code necessary* to reproduce it **in the question itself**. Questions without **a clear problem statement** are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – Gustavo Morales Jun 29 '16 at 09:55

1 Answers1

0

Using service account is not supported by Youtube Analytics and Reporting API

The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Reporting API and YouTube Analytics API do not support this flow. Since there is no way to link a Service Account to a YouTube account, attempts to authorize requests with this flow will generate an error.

Unfortunately, you need to do OAuth2 to get your report.

Resources you can check for information:

Community
  • 1
  • 1
Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91