Vinay Pallegar
Vinay Pallegar

Reputation: 11

Youtube Analytics API with Service Account

I am trying to query my youtube analytics account using a Service Account i created in the console. When i use the token i receive after authentication, i keep receiving a "query did not conform the expectations". Now my main account has two other channels attached to them and one of the other channels is what im trying to query. So my question is if its possible to query another channel that i am the owner of..

If i use the google console playground and do the oauth authentication (and select my other channel) then it works...But otherwise won't...

If anyone has any experience with this api would appreciate any feedback. Thank you in advance for your time.

Upvotes: 1

Views: 1034

Answers (2)

PoorInRichfield
PoorInRichfield

Reputation: 1578

Unfortunately, the answer is no, you can't use a service account to retrieve YouTube analytic data.

See the last statement regarding OAuth 2.0 flows in the Implementing OAuth 2.0 Authorization documentation:

The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Analytics API does 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.

Upvotes: 1

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

You can query it as long as you set the ids parameter right:

To request data for a YouTube user, set the ids parameter value to channel==CHANNEL_ID, where CHANNEL_ID specifies the unique YouTube channel ID. - To request data for a YouTube CMS content owner, set the ids parameter value to contentOwner==OWNER_NAME, where OWNER_NAME is the CMS name of the content owner.

Upvotes: 0

Related Questions