virusss8 virusss8 - 1 year ago 57
Swift Question

iOS Youtube API v3 retrieve my channels


I have a problem with youtube api v3, and I really hit a dead end

So, in my app I have newest GoogleSign-In implemented

let newScope: Array =
GIDSignIn.sharedInstance().scopes = newScope

This shows how I add new scopes.

I successfully sign in user and retreive user id, it's data, access_token etc.

Now that the user is signedin, I need to get his youtubeId/channelId.

I did some research and I found that I can get my channel id with:{API_KEY_HERE}

I even tried to send access_token in url, but with no luck..

But something is wrong and I get 401 status code -

The request uses the
parameter but is not properly

What am I doing wrong?

Here I tested and everything works fine:

result here in sandbox:

"kind": "youtube#channelListResponse",
"etag": "\"XXXXXXX\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
"items": [
"kind": "youtube#channel",
"etag": "\"XXXXX\"",
"id": "XXXXX",
"googlePlusUserId": "ID_ID_ID"

Anyone have idea? solution? proposal?
Thankyou very much

In fact, why am I not authorized if I just successfully signedIn myself??

Tried even adding header for authorization:

Bearer {id_access_token}

Answer Source

I finally found the solution.

Yes, the header needs to be send. The only problem was with token!

When the signIn is successful, you get



That - lets call it "user", have .authentication with userID, idToken and accessToken

In documentation there is only mention of idToken, so I thought that this is actually the access token. How silly of me :/

Lesson learned!