Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:34:07+00:00 2026-06-05T18:34:07+00:00

After spending roughly two days on this, I’m getting a little rattled. Although by

  • 0

After spending roughly two days on this, I’m getting a little rattled. Although by now, having chosen OAuth2 over OpenID, I’m pretty well versed on the difference between Authenticate and Authorize.

I want my android app to provide several ways to authenticate users, one of them is google accounts, and later also facebook and twitter accounts. I’m trying to use the AccountManager class to get an OAuth access token to (for now) just verify the user’s email address. The goal is that if the user already has a google account saved on the android device, they can authorize my app once, MAYBE even without typing a password, and never have to login again from their android.

I decided to use Google’s own AccountManager as it promised to handle much of this natively in the Android framework, without even opening a browser window. I am using the library / build target for google APIs version 7 (Android 2.1), the first level that supports AccountManager.

I have tried this two different ways, one using AccountManager.getAuthTokenByFeatures() where you do not specify an Account object, and the other using getAuthToken() where you do specify such an object.

In each case, the call completes (as I expect it to) and the application displays an authorization dialog asking if I want to authorize the app. So far, so good. If I refuse, the program throws the exception that I expect. If I accept, a “Google sign-in” dialog appears asking me for the password to the account. Note that I already entered the password when I added the account to the device. If I type the password in the dialog, there is an “Authorizing” wait screen and then the same dialog re-appears. Oddly enough, the “Authorizing” wait screen seems to take a little bit longer if I type the CORRECT password. So it appears that I cannot get to the code path where I successfully obtain the token.

As tempting as it is to vent about google not being clear about what AUTH_TOKEN_TYPE is or the fact that the userinfo.email URL is undocumented, I would really just like to learn what I am doing wrong here and move past this.

Here is my code, I will monitor this and of course be happy to answer any questions. Right now I am going to work on getting a capture of the network traffic, to see if that provides any further insight into what is going wrong.

Here are images showing the auth screen (ok) and the password dialog (less ok)
http://imageshack.us/g/707/device20120609020618.png/

    public void loginToGoogle() {
    System.out.println("Starting");
    AccountManagerFuture<Bundle> bundleFuture = 
        AccountManager.get(_activity).getAuthTokenByFeatures(
                "com.google", 
                "https://www.googleapis.com/auth/userinfo.email", 
                null, 
                _activity, 
                null, 
                null, 
                new AccountManagerCallback<Bundle>() {

                      public void run(AccountManagerFuture<Bundle> future) {
                        Bundle bundle;
                        try {
                          bundle = future.getResult();
                          for (String s : bundle.keySet()) {
                              System.out.println("Found key: "+ s);
                          }

                          System.out.println(bundle.getString(AccountManager.KEY_ACCOUNT_NAME));
                          System.out.println(bundle.getString(AccountManager.KEY_AUTHTOKEN));
                          //Use Token


                        } catch (OperationCanceledException e) {
                          Log.e("e", e.getMessage(), e);
                          System.out.println("User appears to have denied auth request");
                        } catch (AuthenticatorException e) {
                          Log.e("e", e.getMessage(), e);
                        } catch (IOException e) {
                          Log.e("e", e.getMessage(), e);
                        }
                      }
                    }, 
                    null);
    System.out.println("Done with AccountManager call");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:34:09+00:00Added an answer on June 5, 2026 at 6:34 pm

    Your issue most likely lies in the Auth Token Type you pass into the getAuthTokenByFeatures. Since you’re using oauth2, you need to add it to beginning of your auth type:

    String AUTH_TOKEN_TYPE = "oauth2:https://www.googleapis.com/auth/userinfo.email"
    

    However, I’m not positive that the Auth Token Type you are trying to use is valid. I’ve only dealt with calendars and tasks myself. Hope this works out, if not, just let me know and I’ll find you the right Auth type

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using IB, but after spending a one or two
I am new to this after spending 2 days trying to find an answer
After spending several hours today searching and seeing several people having the same issue,
After spending SEVERAL frustrated hours on this I am asking for your help. I
After spending a couple months studying DDD methodology, I've now began to apply these
After spending 14 hours on this I think its time to share my woes
After spending half an hour to find a proper, self-explaining title for this question,
After spending a little time wondering why my app was running a particular scenario
after spending 2 solid days searching for an answer, I would like to ask
EDIT: After spending several hours researching this, I don't think I'm going to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.