I’m developing an integration with the YouTube Analytics API to access financial data (estimatedRevenue) for multiple brand accounts (channels) that I manage. I have administrator permissions for all channels, and they are all monetized.
Authentication is being handled through OAuth 2.0, using the following scopes:
https://www.googleapis.com/auth/yt-analytics-monetary.readonlyhttps://www.googleapis.com/auth/yt-analytics.readonly
What I've Tried
- Successful Authentication:
- I can successfully authenticate my main Google account using
client_idandclient_secret. - I’m able to retrieve general data like
viewsandlikesvia the YouTube Data API, but financial data through the YouTube Analytics API remains inaccessible.
- Requests Made for Multiple Channels:
For each channel, I’m using the correct
channelIdand sending the date range in the proper format.Example endpoint used: GET /v2/reports?ids=channel==UCV7p2362kGftQc07bpVomUQ &startDate=2024-09-01 &endDate=2024-09-01 &metrics=estimatedRevenue &dimensions=month &sort=month
- Errors Encountered:
- 401 Unauthorized:"Insufficient permission to access this report."
- 403 Forbidden:"Forbidden."
- OAuth Playground Tests:
- I tested using the OAuth Playground, selecting the correct brand account during authentication and using the appropriate scopes. Despite this, the same errors persist.
- Additional Verifications:
- All channels are monetized and are part of the YouTube Partner Program.
- I am the administrator of all brand accounts and can view financial data in YouTube Studio.
What I’d Like to Know:
- Is it possible to access financial data of brand accounts using the Google account managing them?
- Are there any additional steps required to authorize brand accounts in the API, beyond selecting the correct account during authentication?
- Would the
onBehalfOfContentOwnerparameter apply in this case? If so, how can I obtain and use it correctly? - How can I ensure the scopes used are sufficient to access
estimatedRevenuedata?
What I've Reviewed:
Discussions on Stack Overflow with the tags:
youtube-api,youtube-analytics-api, andoauth-2.0.