I have used YouTube Reporting API in Google Apps Script. Despite the no code changes, Forbidden is now thrown January 12th.
In reference to Google's document, I wrote the following code.
var myChannels = YouTube.Channels.list('id', {mine: true});
var channel = myChannels.items[0];
var today = new Date();
var todayFormatted = Utilities.formatDate(today, 'JST', 'yyyy-MM-dd');
var videoId = "MY_VIDEO_ID";
try {
var results = YouTubeAnalytics.Reports.query(
'channel==' + channel.id,
todayFormatted,
todayFormatted,
'views',
{
dimensions: 'day',
sort: '-day',
filters:'video==' + videoId
});
} catch (e) {
Logger.log(e) //Exception: Forbidden
}
OAuth authentication, YouTube Analytics API has been enabled in the Google Developer Console and Advanced Google Services.
I think there is a problem with my account, but is going the same problem in other accounts. Strangely, it will work normally in APIs Explorer.
Perhaps, this is the same problem as the post below.
Cause, I believe because does not contain the "yt-analytics.readonly" to OAUTH2 SCOPES.
In fact, it had been included yt-analytics.readonly to APIs Explorer in OAUTH2 SCOPES. So, it could successfully run. Perhaps, even before January 12. However, in spite of using youtube analytics api in this script, it does not contain a yt-analytics.readonly.
Why such a problem is happening?