1

A rather important portion of my app is the ability for users to sign in with Google Accounts. For the version of the app on the Play Store, I'm already using the AccountManager and Google Play Services. The issue I'm having now is how to fall back to using regular oauth for devices that don't have GPS installed (like Kindles).

The general idea that I had was to pop open the user's default web browser with a callback url (handled in the AndroidManifest) so I could grab the oauth token from there:

public void requestTokenFallback(){
    Uri.Builder builder = new Uri.Builder().scheme("https")
            .authority("accounts.google.com")
            .appendPath("o")
            .appendPath("oauth2")
            .appendPath("auth")
            .appendQueryParameter("response_type", "token")
            .appendQueryParameter("client_id", CLIENTID)
            .appendQueryParameter("scope", SCOPE)
            .appendQueryParameter("redirect_uri", "myapp-oauth");
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, builder.build());
    activity.startActivity(browserIntent);
}

If I set response_type to "code", it allows me to login and gives me a token to copy and paste. If I set it to "token" and use redirect_uri urn:ietf:wg:oauth:2.0:oob (since that's what's in the Google API Console), I get a message that "redirect_uri not supported for response_type=token: urn:ietf:wg:oauth:2.0:oob"

The issue that I'm having is that I can't figure out how to configure this on the Google API console side of things to allow me to set up myapp-oauth://access_token:XXXXXXXXX as the address that the OAuth flow redirects to.

Any ideas?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.