Java – The AUTH_TOKEN TYPE of the Google API

The AUTH_TOKEN TYPE of the Google API… here is a solution to the problem.

The AUTH_TOKEN TYPE of the Google API

Ok, so I know how to get a list of accounts so that I can let users verify my app to use their Google data, however, I’m confused about what my AUTH_TOKEN_TYPE uses>

Here is my current code :

AccountManager.get(this).getAuthTokenByFeatures("com.google", AUTH_TOKEN_TYPE, null, this, null,null)

I

don’t know where to find the AUTH_TOKEN_TYPE for the Picasa API (and all the other Google APIs) I want to use. Does it help?

Solution

AUTH_TOKEN_TYPE is the OAuth scope of the API to use. In order for the account manager to understand that it is OAuth2.0, you need to append “oauth2:” to it. So, for example, for the task API, it looks like this.

String AUTH_TOKEN_TYPE = "oauth2:https://www.googleapis.com/auth/tasks";

For Picasa it will be

String AUTH_TOKEN_TYPE = "oauth2:https://picasaweb.google.com/data/"

EDIT: Some Google APIs provide the use of special alias strings instead of writing the entire OAuth2 scope. For example< a href="http://code.google.com/apis/tasks/oauth-android-auth-token-type-aliases.html" rel="noreferrer noopener nofollow">here is a AUTH_TOKEN_TYPE alias for the Google Tasks API.

Related Problems and Solutions