9

Is it possible to get all the channels associated with a logged in user account, using youtube's version 3 API (https://developers.google.com/apis-explorer/#p/youtube/v3/).

The nearest call that I can see for YouTube.channels.list

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list

I attempt to use this by 'Authorizing the requests using OAuth 2.0' I select part=snippet and mine=true

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=snippet&mine=true&_h=1&

but this only brings back the single channel not any of the other channels associated with the account, but the account I'm using has several channels. I need to get all channels for logged in user so I can give them the choice of what channel they are using, especially now google have messed YouTube around with the Google plus integration.

Does anybody know if this is possible?

Trikaldarshiii
  • 11,174
  • 16
  • 67
  • 95
Hevski
  • 1,821
  • 1
  • 17
  • 26

2 Answers2

7

Found the answer in YouTube's API Blog here:

http://apiblog.youtube.com/2013/06/google-page-identities-and-youtube-api.html According to this as I'm using Android with OAuth2 there is no native Android account switcher, and

the then the API will choose the “wrong” channel in some cases, or even no channel (e.g., if the personal account doesn’t have a channel).

So I've got two options When this happens, the user has two options to specify the correct channel:

  • Use the Advanced Account Settings tool to select which channel should be used. This is recommended when a user has one channel they want to use for all applications.

  • Set up login credentials for each of their Google+ pages, and specify those > credentials, not their normal Google Account credentials, for each application that needs access.

Both these options require the user to do something outside the boundary of the Android Application, so both solutions are not usable. Unfortunatly this piece of functionality will have to wait until Android has some better way of switching the channel for the user...

Hevski
  • 1,821
  • 1
  • 17
  • 26
5

OAuth2 allows login in with only one channel, so that's not possible.

OAuth2 already gives user a choice to pick the channel they want to authorize and give access, so you don't have to implement it anyways.

Ibrahim Ulukaya
  • 12,767
  • 1
  • 33
  • 36
  • 1
    Thanks for the reply, how does OAuth2 go about giving the user choice of the channel they want to authorize. I'm using android and integrate the application with google play services, an account picker (from google play services) is shown to the user and when the user selects the account in the code we create a new googleAccountCredential from package com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential; – Hevski Nov 19 '13 at 13:58
  • 1
    The code I use is GoogleAccountCredential.usingOAuth2(YTSubBrowserApp.getAppContext(), YouTubeScopes.YOUTUBE_READONLY); google_Account_Credential.setSelectedAccountName(appState.userSettings.getStrLoggedInGoolgleAccountEmailAddress()); I catch UserRecoverableAuthIOException startActivityForResult based on that intent in the exception,to authorise the credential. At no point is channel selector dialog presented to the user. – Hevski Nov 19 '13 at 14:01
  • Also why doesn't the API Explorer allow you to select different channels when you Authorize requests using OAuth 2? it just picks up the channel that is associated with google account i'm currently logged in as. – Hevski Nov 19 '13 at 14:11
  • 1
    It appears that channel picker is only available in the web version of Oauth2, as I'm using the Android version I stuffed – Hevski Nov 19 '13 at 16:25
  • @Hevski have you solved the problem? this is ridiculous, apparently the only way to get this working is to use the web based oauth. – Pierfrancesco Soffritti Jun 09 '16 at 15:36
  • 1
    @code511788465541441 i think my answer as of nov 2013 was correct, but this may well have change v3 of the api was released. So things might have changed. But I never resolved it in 2013 and haven't needed to chase up solution. Post it here if you find an update, thanks – Hevski Jan 06 '18 at 17:35