In my web app, I have to ask the users for permission to access their YouTube channels.
The authentication url is something like this:
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!!
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.
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.