How do I get metrics for youtube users? - youtube

I am new to youtube APIs, I am trying the API explorer here : https://developers.google.com/youtube/analytics/v1/
I am trying to get details about a particular youtube user. I am entering the following things to execute the method in the API explorer :
channel id, start date, end date and metrics. When I execute i get the following 403 Forbidden error with you do not have permission to execute this method as a message.
All the details I am entering are correct.
Does youtube doesnt allow to fetch details of other users ? If it allows, what am I doing wrong here? Thanks !

Unless you are a CMS that manages the channel you are requesting data for, Youtube will not allow you to access their analytics data. The analytics API only allows you to request data for the channels owned by the current authenticated user.

Related

How to get logged in user youtube details using youtube data api v3

how to get logged in user youtube details in react
had tried using javascript but is there any ways to get ?
i want get youtube details of logged in user , like number of videos and subscribers in react.
The YouTube data api is channel based not user based. There for any information you get back about the currently logged in Channel is not going to be user related.
Request the profile scope and then go though the Google People api.

Youtube reporting API HttpError 403 error

On my google account (not a Primary account), I have created OAuth credentials which have access to CMS and it's Channels. Using this credentials I am able to fetch data from YouTube Analytics API, so here no problem.
However, when I am trying access YouTube Reporting API, I am only getting the list of reports of Content Owners Reports with an addition of onBehalfOfContentOwner=cms._id parameter and the CMS ID.
def list_report_types(cms):
reporting = youtube.reporting()
request = reporting.reportTypes().list(onBehalfOfContentOwner=cms._id)
results = youtube.query(request)
return results.get('reportTypes')
report_types = list_report_types(cms)
Can anyone help me to also get the list of reports of Channels also?
So when I try to schedule a channel_basic_a2 report, it gives me below error
HttpError 403 when requesting https://youtubereporting.googleapis.com/v1/jobs?alt=json&onBehalfOfContentOwner=cmsid returned "The caller does not have permission">
Thanks in advance.
Two possible issues:
Are the oauth credentials you are using service account credentials? Service accounts do not work for the Youtube Reporting API. See this answer.
Also, have you checked your scopes definition?

How to get Youtube video views by date range

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.
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:
Youtube Analytics API PHP Invalid query. Query did not conform to the expectations
Implement OAuth 2.0 Authorization

Youtube Content ID API has not been used - error 403

I'm trying to get my content-owner-id for upload videos to other channels that I have, as described here.
I'm using the code below to get content-owner-id: (PHP)
$youtubePartner = new Google_Service_YouTubePartner($this->client);
$contentOwnersListResponse = $youtubePartner->contentOwners->listContentOwners(
array('fetchMine' => true));
$contentOwnerId = $contentOwnersListResponse['items'][0]['id'];
And this is the error I got:
A service error occurred: Error calling GET
googleapis.com/youtube/partner/v1/contentOwners?fetchMine=true:
(403) Access Not Configured. Youtube Content ID API has not been used
in project XXXXXXXXXXXXX before or it is disabled. Enable it by
visiting
console.developers.google.com/apis/api/youtubePartner/overview?project=XXXXXXXXXX
then retry. If you enabled this API recently, wait a few minutes for
the action to propagate to our systems and retry.
I tried to go the the link https://console.developers.google.com/apis/api/youtubePartner/overview?project=XXXXXXXXXX but I get "The API doesn't exist or you don't have permission to access it".
Then I searched on google and find out that I need to become a CMS youtube account (I'm also a youtube partner). I also tried to go to cms.youtube.com and log in with my youtube account but I got:
Your Google Account is not linked with YouTube Content Manager. Please
try a different account or contact your Technical Account Manager for
assistance.
Can anyone explain me how to connect to CMS account?
Based from this thread:
You don't see it in the list auf available APIs, unless your account is connected to a CMS and some time has past... It takes 7-14 days unless the Content ID API is available for your account. This is a information i got from the support, but they told me, that it is an automated step.
Your account needs to be connected with a content owner. Be noted that a content owner and a partnered channel are not the same thing.
From this documentation, to request data from a YouTube Content Owner, you need to set the ids parameter value to contentOwner==OWNER_NAME, where OWNER_NAME is the content owner ID.
Check these related SO questions:
How do I get revenue reports from a YouTube CMS account using an API (for an MCN)?
Using the YouTube Analytics API with a CMS account

Response message is forbidden when queried for video on youtube analytics api

I used the youtube analytics api console ([https://developers.google.com/apis-explorer/#p/youtubeAnalytics/v1/youtubeAnalytics.reports.query?][1]) to retrieve details of videos (from my channel), values for id : channel==4aYYO.... metrics : video .
The response I get is 403 Forbidden code: 403, message: "Forbidden
Can anyone point out if I am missing any permission ?
[1]: https://developers.google.com/apis-explorer/#p/youtubeAnalytics/v1/youtubeAnalytics.reports.query?
Channel ids begin with UC. Can you try UC4aYYO... and see if that works?
First, use the ChannelList method in the YouTube Data API to your Channel ID's. This must be an authenticated call, so click the Authorize Requests slider in the API explorer. Make sure you are logged in with the Google account which owns the channel.
API Explorer Query
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=snippet&mine=true&_h=1&
Here is more explanation from Jeff at Google.
How do I get a list of YouTube channels, and associated channel URLs (user or channel), owned by an authenticated user

Resources