Search code examples
androidoauth-2.0google-apiyoutube-apiandroid-youtube-api

Get access token for more than one scope from GoogleAPI's in Android


I have an application which requests youtube data api's. I need to have access token for some request like to get video's, playlist etc. For this I can simply use GoogleAuthUtil class to get Token by calling:

String access_token = GoogleAuthUtil.getToken(Context, userEmail, "oauth2:https://www.googleapis.com/auth/youtube");

Where third parameter is a Scope to get access token for particular request. Now I want to make a request which accepts 4 scope to give token back. And this method takes only one scope as an argument.

Is there a way to get access token with more than one scope in Android.


Solution

  • According to the Google docs,

    "String representing the authentication scope. To specify multiple scopes, separate them with a space (for example, "oauth2:scope1 scope2 scope3")."

    Also that such method is deprecated and you should use the "getTokenWithNotification" version.