I'm running a service where people can connect their Google account using oauth 2.0, and with YouTube permissions I can manage their channels/access their YouTube Channel ID.
However, my question is whether or not you can go backwards. i.e. How can you determine the Google Account Owner from a given YouTube channel ID?
googlePlusUserId is now deprecated from
https://developers.google.com/youtube/v3/docs/channels#properties
contentDetails.googlePlusUserId
no longer exists as part of the contentDetails part.
Based on this excerpt from their change-log
June 13, 2016
This update contains the following changes:
- The
channel
resource'scontentDetails.googlePlusUserId
property has been deprecated. Previously, the property was only present if the channel was associated with a Google+ profile. Following the deprecation, the property will no longer be included in anychannel
resources.- The
comment
resource'ssnippet.authorGoogleplusProfileUrl
property has been deprecated. Previously, the property was only present if the channel was associated with a Google+ profile. Following the deprecation, the property will no longer be included in anycomment
resources.Since neither of these properties will be returned following the deprecation, both properties have been removed from the corresponding resource documentation.
You can get user Google+ ID through a YouTube API(v3) request, e.g.:
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id={CHANNEL_ID}&key={YOUR_API_KEY}
Will return:
{
"kind": "youtube#channelListResponse",
"etag": "fooHash",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [{
"kind": "youtube#channel",
"etag": "fooHash",
"id": "fooHash",
"contentDetails": {
"relatedPlaylists": {
"likes": "fooHash",
"favorites": "fooHash",
"uploads": "fooHash"
},
}
"googlePlusUserId": "{ID}"
}]
}
Probably people can not get Google+ ID from YouTube API(v3). But even the channel owner did not create google plus account, you can know it in advance on the channel HTML document by using XHR or curl.
visit channel page.
Catch Javascript object from Developer tool on browser at the page.
ytInitialData.metadata.channelMetadataRenderer.ownerUrls
[ "http://www.youtube.com/user/googlechrome",
"https://plus.google.com/100585555255542998765" ]Second one is always google plus address and the number is Google+ ID. You can get more info from ytInitialData at the channel page if necessary.
One example. https://www.youtube.com/channel/UCiQPrVjbUlZBWY0fVtvpoKg
About that channel id(UCiQPrVjbUlZBWY0fVtvpoKg) You can not get Google+ ID from YouTube API(v3), but you can get Google+ ID at the channel directly when you can access html document or read it. Even if the channel owner did not create google plus account, the Youtube already made Google+ ID together.
来源:https://stackoverflow.com/questions/35823274/how-to-get-a-users-google-id-from-a-youtube-channel-id