So, I have a valid OAuth token for a channel. When the token expires, it is automatically refreshed. This token works for requests to gdata.youtube.com
, but for some reason is denied to www.googleapis.com/youtube/analytics/v1/reports
.
The scope used to get the token is https://gdata.youtube.com https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/youtubepartner
This works for other channels but not the one in particular.
GET www.googleapis.com/youtube/analytics/v1/reports
PARAMS
?metrics=views
&ids=channel==...
&start-date=...
&end-date=...
HEADER
Authorization: Bearer ...
RESPONSE
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
Edit: it should be noted that when you call www.googleapis.com/youtube/analytics/v1/reports
with insufficient scope, you get this error:
{domain:global, reason:insufficientPermissions, message:Insufficient Permission}
This is a completely different error from the 403 forbidden one.
A 403 Forbidden Error occurs when you do not have permission to access a web page or something else on a web server. It's usually a problem with the website itself. However, you can try refreshing the page, clearing your cache and cookies, and disconnecting from any VPN you might be using.
Description. forbidden (403) forbidden. Access forbidden. The request may not be properly authorized.
You probably need to enable YouTube Analytics for your project. Go the the APIs console: https://code.google.com/apis/console, select your project, then click on the services tab, search for YouTube Analytics, and enable it, after reading and accepting the ToS. Remember to validate that the free quota is sufficient for your uses or request additional quota.
We came across the same permissions error. Unless the user is apart of the Youtube Partner Program, you'll be unable to retrieve the content owner reports:
https://developers.google.com/youtube/analytics/v1/content_owner_reports
"Note: Content owner reports are only accessible to YouTube content partners who participate in the YouTube Partner Program."
But you can still retrieve the Channel Reports for regular users:
https://developers.google.com/youtube/analytics/v1/channel_reports
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With