Reputation: 31
I'm trying to get my YouTube Brand channel's live streaming chat data using YouTube Live Streaming API, on Google AppsScript.
I can see list of my Brand channels from this page > https://myaccount.google.com/brandaccounts
I made OAuth2 service and authenticated with my Google account. I can find access token from the service. (code below)
But when I trying to get list of my channels from https://www.googleapis.com/youtube/v3/channels with mine=true, it only returns one of my channels which is not branded one. (Now I deleted that channel and channels API returns no channel)
here's my code:
function getYouTubeService() {
return OAuth2.createService('YouTube')
.setAuthorizationBaseUrl('https://accounts.google.com/o/oauth2/auth')
.setTokenUrl('https://oauth2.googleapis.com/token')
.setClientId('{my client id of webapp here}')
.setClientSecret('{my client secret of webapp here}')
.setCallbackFunction('authCallback')
.setScope([
'https://www.googleapis.com/auth/youtube.readonly',
'https://www.googleapis.com/auth/youtube.force-ssl'
])
.setPropertyStore(PropertiesService.getUserProperties());
}
function getChannelsList() {
const service = getYouTubeService();
if (!service.hasAccess()) {
const authorizationUrl = service.getAuthorizationUrl();
console.log(service.getAuthorizationUrl());
return;
}
const token = service.getAccessToken();
var url = `https://www.googleapis.com/youtube/v3/channels`
+ `?part=snippet`
+ `&mine=true`
;
const options = {
method: 'get',
headers: {
Authorization: `Bearer ${token}`,
},
muteHttpExceptions: true,
};
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
console.log(JSON.stringify(data, null, 5));
}
I've spent hours consulting with GPT, trying various tests, keep getting succeeded to get other channel's public statistics using API but cannot reach my brand channels.
I no longer know what else to look at. Please help me.
Upvotes: 0
Views: 14