0
votes

Now you can create more than one Youtube channel. In my Android app I need to let user select one of these channels and work with it (get subscription videos, etc..).

I'd like to emulate the official Youtube app where you can choose one of my channels that I have created in my Youtube account.

EDIT:

Finally I solved the problem with the Ibrahim suggestion. In a webview I used the oAuth2 authentication like this:

https://accounts.google.com/o/oauth2/auth?client_id=CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/youtube&response_type=code&access_type=offline

Then receive the token to use to get the access_token:

String url = "https://accounts.google.com/o/oauth2/token";

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5);

nameValuePairs.add(new BasicNameValuePair("grant_type", "authorization_code"));
nameValuePairs.add(new BasicNameValuePair("client_id", YoutubeBase.CLIENT_ID_NUMBER));
nameValuePairs.add(new BasicNameValuePair("client_secret", YoutubeBase.CLIENT_SECRET));
nameValuePairs.add(new BasicNameValuePair("code", code));
nameValuePairs.add(new BasicNameValuePair("redirect_uri", YoutubeBase.REDIRECT_URI));
response = RestClient.postGoogleData(url, nameValuePairs);

And finally use the access_token to call to Youtube Data API:

https://gdata.youtube.com/feeds/api/users/default?v2.1&access_token=" + accesToken

I've used with API v2 but works with v3.

1

1 Answers

3
votes

There is no Page selector built-in with the current Android native OAuth2 client. Till that is built, the only workaround is that, doing the web version Oauth2, get the token, and use that token in your requests later on.