I'm writing a standalone Google Apps Script that will query the Youtube Reports API and return analytics on my videos.
When I authenticate in Apps Script with one of the Google+ pages that we use to manage our various Youtube Channels, Apps Script keeps asking me to authorize the script for offline access.
When I try the same thing in a new script project with my personal gmail account, everything works fine. There's a problem with doing it this way though. When I query the Youtube.Channels.list through my own account, I don't get a list of any of the other channels I own, just my own personal channel.
I've also tried this with the try it feature on the Youtube documentation with a Google+ page and things work fine.
For this script, I have the following advanced services turned on & enabled in the Google Developer Console:
- Youtube Data API
- Youtube Analytics API
- Google+ API (just in case)
I've also tried specifically setting the channel id to channel==xxx and removing the varibles MyChannels and channel and I still get the same results.
What could be a possible solution?
Here's an example of my code:
function youTubeAnalytics() {
var myChannels = YouTube.Channels.list('id', {mine: true});
var channel = myChannels.items[0];
var channelId = channel.id;
var analyticsResponse = YouTubeAnalytics.Reports.query(
'channel==' + channelId,
'estimatedMinutesWatched,views,likes,subscribersGained',
{dimensions: 'video','max-results': '200',sort: '-views'});
}