Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube API get Google+ ID from Youtube User Name

Tags:

youtube

api

I have a youtube username and channel ID from youtube.

https://www.youtube.com/user/scottmillerstyle

I need to find the user associated with scottmillerstyle

Is there a way to use the YouTube data API to access the Google+ user name of the person who set up the channel?

I've been working with the API explorer but haven't been able to find a solution in this direction.

https://developers.google.com/youtube/v3/docs/channels/list

like image 733
Andrew Woodard Avatar asked Nov 17 '15 19:11

Andrew Woodard


1 Answers

It's possible, but only if the user authenticates using an app you develop.

Check out this response:

 cache-control:  private, max-age=0, must-revalidate, no-transform
 content-encoding:  gzip
 content-length:  255
 content-type:  application/json; charset=UTF-8
 date:  Thu, 18 Feb 2016 19:15:40 GMT
 etag:  "DsOZ7qVJA4mxdTxZeNzis6uE6ck/Oq_w72Shc0Jbz1xT23RTCTTrK_w"
 expires:  Thu, 18 Feb 2016 19:15:40 GMT
 server:  GSE
 vary:  Origin, X-Origin
 {
   "kind": "youtube#channelListResponse",
   "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/Oq_w72Shc0Jbz1xT23RTCTTrK_w\"",
   "pageInfo": {
   "totalResults": 1,
   "resultsPerPage": 5
  },
  "items": [
   {

    "kind": "youtube#channel",
    "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/MmJKFbszvNpjgkX8YAJ4HGIfQ5E\"",
    "id": "UC_VbgAPtgDGLyRMTEBqzRaA"
   }
  ]
 }

You can duplicate this by doing the following:

Visit the URL you provided: https://developers.google.com/youtube/v3/docs/channels/list

Scroll down to Try it! and input:

 Part:            contentOwnerDetails
 forUsername:     scottmillerstyle

Hit Execute. It will ask for authentication and then show you the response.

Here Youtube documents Channel ID = (UC + User ID) https://support.google.com/youtube/answer/3250431?hl=en

So now you know the YouTube user ID is _VbgAPtgDGLyRMTEBqzRaA. So now we have to figure out how to translate YouTube user ID into Google+ ID...

I found this: https://developers.google.com/+/web/api/rest/latest/people/get

This will get Username, Email, Lots of Details from a Google+ ID... But there is nothing left to connect the dots between the YouTube ID and the Google+ ID. Google must deem the connection a security risk. Lets take a look at how I determined this.

Visit this link again:

https://developers.google.com/youtube/v3/docs/channels/list

Scroll down to Try it! and input:

 part: contentDetails
 mine: true

Hit Execute. It will ask to authenticate and the response will show:

 200 OK
 - SHOW HEADERS -
 {
  "kind": "youtube#channelListResponse",
  "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/KzUqsPYNzzdoMWr6xkZBKK1GNNg\"",
  "pageInfo": {
   "totalResults": 1,
   "resultsPerPage": 1
  },
  "items": [
   {

    "kind": "youtube#channel",
    "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/IR1I4xHnZMxcbo2sT4BipUVBl-Y\"",
    "id": "UCkoYb87EdaF5XepEa5EmSgQ",
    "contentDetails": {
     "relatedPlaylists": {
      "likes": "LLkoYb87EdaF5XepEa5EmSgQ",
      "favorites": "FLkoYb87EdaF5XepEa5EmSgQ",
      "uploads": "UUkoYb87EdaF5XepEa5EmSgQ",
      "watchHistory": "HLkoYb87EdaF5XepEa5EmSgQ",
      "watchLater": "WLkoYb87EdaF5XepEa5EmSgQ"
     },
     "googlePlusUserId": "YOUR GOOGLE+ ID! FANTASTIC!"
    }
   }
  ]
 }

Now try the same thing, but to get scottmillerstyle ID:

 part: contentDetails
 forUsername: scottmillerstyle
          OR
 id:UC_VbgAPtgDGLyRMTEBqzRaA

And you get this result with no Google+ ID

 200 OK
 - SHOW HEADERS -
 {
  "kind": "youtube#channelListResponse",
  "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/zi31_NL3JJhpDcdJWbxbZE-0Ik8\"",
  "pageInfo": {
   "totalResults": 1,
   "resultsPerPage": 1
  },
  "items": [
   {

    "kind": "youtube#channel",
    "etag": "\"DsOZ7qVJA4mxdTxZeNzis6uE6ck/8iJ_z543bWUuMxbs2hC_VTdTvZI\"",
    "id": "UC_VbgAPtgDGLyRMTEBqzRaA",
    "contentDetails": {
     "relatedPlaylists": {
      "likes": "LL_VbgAPtgDGLyRMTEBqzRaA",
      "uploads": "UU_VbgAPtgDGLyRMTEBqzRaA"
     }
    }
   }
  ]
 }
like image 139
Kyle Burkett Avatar answered Nov 06 '22 03:11

Kyle Burkett