0

In my web app, I have to ask the users for permission to access their YouTube channels.

The authentication url is something like this:

"https://accounts.google.com/o/oauth2/auth?client_id=myClientId&redirect_uri=http://my.redirect.uri&scope=https://www.googleapis.com/auth/youtube.readonly&response_type=code&access_type=offline&approval_prompt=force"

This URL prompts the user to choose a YouTube channel. But in the channel list, the Google/YouTube account also appears. This account isn't linked with any channels directly.

In my app, the users are supposed to select only a channel. My question is, how can I tell if the user selected a channel and not the Google/YouTube account? Is there some method in the YouTube API that can help me know?

I noticed that if the user has selected a channel and I call the channels/list method then the information it returns is as expected but if I call the same method having selected the Google/YouTube account then the channel title is empty. But I'd like to know if there is some other (nicer and cleaner) way to tell if the user has selected a channel or an account.

Thanks!!

Neets
  • 4,094
  • 10
  • 34
  • 46

2 Answers2

1

The appropriate way of doing this is to make the youtube.channels.list(mine=true, part='snippet') call that you suggest, and to check to see what comes back.

I'm not aware of any "better" approach.

Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167
1

From the response of youtube.channels.list(mine=true, part='snippet, status, contentDetails') call, you can check status.isLinked and contentDetails.googlePlusUserId to get a hint. If it's not linked, you have a channel, if it's linked, it could be either of them. Then you can follow your title approach etc. There is not a definite filter for this.

If you elaborate on your use case, maybe there is a better solution we can suggest.

Ibrahim Ulukaya
  • 12,767
  • 1
  • 33
  • 36
  • There's not much to elaborate on, really... what my app does is it gets activity information from the channel (videos and its comments, etc...). So if the user selects an account, it won't have this kind of info. – Neets Jan 29 '14 at 08:15