How do I get revenue reports from a YouTube CMS account using an API (for an MCN)?

后端 未结 1 1054
别那么骄傲
别那么骄傲 2020-12-16 07:39

I have access to a YouTube CMS account (for an MCN). On YouTube I can do lots and lots of things with it and this also includes downloading CSV reports which contain detaile

相关标签:
1条回答
  • 2020-12-16 08:07

    First of all, the CMS account is not a separate account you can log in via Oath. It is more like a privilege and it is connected to one of your google/youtube accounts. This is in contrast to youtube's regular channel-management, where each channel has it's own login credentials.

    Youtube Account Selector

    I attached a screenshot of my youtube account-selector-view, where the CMS belongs to the account name@email.com, which is also the account you have to use for oauth authorization to access your CMS reports.

    Furthermore you can see the name of the CMS, in this case it "CMSName". So, generally this is the name you would use for contentOwner==CMSName. However, your CMS Name seems to include whitespaces. Unfortunately, i cannot reconstruct this case because of missing admin-rights, but i would suggest you the _ for whitespaces too, because " " and "%20" do not map the regular expression for valid params.

    But you said, that you had no success by trying it. But there are too error scenarios:

    1. 403 Forbidden: The name of the CMS could either be wrong or the selected OAth account does not have the required privileges. Do you have all required Scopes and selected the correct account?

    2. 400 Bad Request: This happens when the request is invalid per se. So if you choose contentOwner==CMSName as ids param, a filter parameter is always required, e.g. channel==[ChannelIdForWhichIHaveCMSRights]. So, a API request, that should generally work, would look like this: https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3D[CONTENTOWNER_ID]&start-date=2015-01-01&end-date=2015-01-15&metrics=views&filters=channel%3D%3D[CHANNEL_ID_WITH_CMS_RIGHTS]&access_token=[OATH_TOKEN_FOR_RIGHT_ACCOUNT]

    If both cases won't work for you and you're still getting 403 errors, let us do some debugging and try to fetch the content Owner Id. I will now introduce the YouTube Content ID API https://developers.google.com/youtube/partner/.

    A few words in advance: You have to activate the API in your developer console, like any other API you want to use for your app. BUT:

    Note: The YouTube Content ID API is intended for use by YouTube content partners and is not accessible to all developers or to all YouTube users. If you do not see the YouTube Content ID API as one of the services listed in the Google Developers Console, see www.youtube.com/partner to learn more about the YouTube Partner Program.
    

    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.

    So, now lets assume, that you already have access to the Content ID API.

    You can fetch a list of contentOwnerShips that belong to an account. You can use the API explorer https://developers.google.com/youtube/partner/docs/v1/contentOwners/list#try-it just use as param fetchMine=true and authorize with the https://www.googleapis.com/auth/youtubepartner-content-owner-readonly scope. The response looks like this:

    { "kind": "youtubePartner#contentOwnerList", "items": [ { "kind": "youtubePartner#contentOwner", "id": "[CMS_ID]", "displayName": "[DisplayName]", "primaryNotificationEmails": [ "mail@random.xx" ], "conflictNotificationEmail": "mail@random.xx", "disputeNotificationEmails": [ "mail@random.xx" ], "fingerprintReportNotificationEmails": [ "mail@random.xx" ] } ] }

    This is where you get your CMS_ID from, you can also use it for any API Request as onBehalfOfContentOwner.

    To get a list of all channels that belong to the ownership, simply make this request

            "https://www.googleapis.com/youtube/v3/channels?part=contentDetails&managedByMe=true&onBehalfOfContentOwner=[CONTENTOWNER]&access_token=[ACCESS_TOKEN]"
    

    But this request requires the granted "https://www.googleapis.com/auth/youtubepartner" scope.

    Hoe this could help you, feel free to ask further questions.

    0 讨论(0)
提交回复
热议问题