Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Trouble Retrieving YouTube Channel Report with Google Analytics API: 403 Forbidden Error

$
0
0

I want to generate a report for a YouTube channel for which I have administrator access, using the Google Analytics API. (I'm not channel owner.)

However, when executing the following code in GAS, I receive a 403 Forbidden error.

const channels = YouTube.Channels.list('id,contentDetails', {  id: "hogehoge"});const channelId = channels.items[0].id;const oneMonthInMillis = 1000 * 60 * 60 * 24 * 30;const today = new Date();const lastMonth = new Date(today.getTime() - oneMonthInMillis);const metrics = ['views',];const result = YouTubeAnalytics.Reports.query({  ids: 'channel=='+ channelId,  startDate: formatDateString(lastMonth),  endDate: formatDateString(today),  metrics: metrics.join(','),  dimensions: 'day',  sort: 'day',});

I am referring to the documentation at https://developers.google.com/apps-script/advanced/youtube-analytics?hl=ja.

How can I retrieve the report? Or is this issue related to permissions and therefore, data cannot be output?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>