Hello, we’re using a custom social connection to get users’ youtube channel data. (We can’t use the built-in google connection because it automatically requests the “Manage” permission for youtube and that’s a nonstarter for our users.)
We have the authentication working and returning the user profile. We’ve also added the youtube.readonly
scope to the social connection and the YouTube data returns in the Fetch User Profile Script, but we aren’t able to add the channels array (or any custom fields) to the returning profile object and have it come back in our app. We have also tried adding the data to user_metadata
without any luck.
How can we return the YT channels to our app just like the built-in google connection does?
Thanks in advance — here is our fetch script:
function (accessToken, ctx, cb) {
const urlRoot = `https://youtube.googleapis.com/youtube/v3/channels`;
const params = [
`key=xxx`,
'mine=true',
'part=id,snippet',
];
const url = `${urlRoot}?${params.join('&')}`;
const profileData = jwt.decode(ctx.id_token)
request.get(
{
url: url,
headers: {
'Authorization': `Bearer ${accessToken}`,
'Client-Id': ctx.options.client_id
},
json: true
},
(err, resp, body) => {
const channels = body && Array.isArray(body.items) ? [...body.items] : [];
const profile = {
user_id: profileData.sub,
email: profileData.email,
channels: channels // doesn't return to our app
};
cb(null, profile);
}
);
}