ksloan
ksloan

Reputation: 1492

How to get a user's Google+ ID from a YouTube channel ID

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?

Upvotes: 4

Views: 6886

Answers (3)

JH SON
JH SON

Reputation: 31

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.

  1. visit channel page.

    https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ

  2. 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" ]

  3. 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.

Upvotes: 3

Michael Waltman
Michael Waltman

Reputation: 36

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's contentDetails.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 any channel resources.
  • The comment resource's snippet.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 any comment resources.

Since neither of these properties will be returned following the deprecation, both properties have been removed from the corresponding resource documentation.

Upvotes: 2

Leonardo Ortiz
Leonardo Ortiz

Reputation: 31

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}"
   }]
}

Upvotes: 1

Related Questions