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 8036057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:29:35+00:00 2026-06-05T02:29:35+00:00

I am not a programmer, but I need to do this myself. I need

  • 0

I am not a programmer, but I need to do this myself. I need some help.

I have been looking for the solution for the last two days and I cannot find any.

Ok. I am writing Android Native App. My first goal is to achieve possibility of login through Google Account (which is already set on the phone).

So I am using AccountManager to get the “com.google” account, I am getting an auth token this way:

Account[] mAccounts = mAccountManager.getAccountsByType("com.google"); 
AccountManagerFuture<Bundle> response = 
    mAccountManager.getAuthToken(mAccounts[0], "android", null, this, null, null);

Bundle authTokenBundle;
String authToken;

try {
    authTokenBundle = response.getResult();
    authToken = authTokenBundle.getString(AccountManager.KEY_AUTHTOKEN).toString();
} catch (OperationCanceledException e) {
    Log.e(TAG, e.getMessage());
} catch (AuthenticatorException e) {
    Log.e(TAG, e.getMessage());
} catch (IOException e) {
    Log.e(TAG, e.getMessage());
}

And my question is – what should be my next step? How I can go further with this authentication process? How should I use this token?

I have found some resources, but most of them are using OAuth or are web-based. I only need to authenticate and (if it is possible) get the name of the user (I already have the e-mail address), I don’t need to access any Google services.

Thank You in advance.

  • 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-05T02:29:36+00:00Added an answer on June 5, 2026 at 2:29 am

    Actually, OAuth 2 is what you want, rather than OpenID — OpenID is inherently web-based, so you’d need to jump through some hoops with WebView or the browser. OAuth 2 allows you to use the token from AccountManager with Google APIs right from the app.

    In your call to getAuthToken(), the authTokenType parameter is the OAuth 2 scope, which you want to be userinfo.profile and userinfo.email to authenticate the email address (you already have it, but you haven’t verified it; it could in theory be spoofed) and to get the name of the user.

    Here’s what I use for the full scope in a similar situation:

    private static final String OAUTH2_SCOPE =
        "oauth2:" +
        "https://www.googleapis.com/auth/userinfo.profile" +
        " " +
        "https://www.googleapis.com/auth/userinfo.email";
    

    Of course, you could just use the whole string literal inline, but I prefer to build it up and be clear, and it makes it easier to change later if necessary.

    In my case, I use getAuthTokenByFeatures(), something like this:

    am.getAuthTokenByFeatures("com.google", OAUTH2_SCOPE, null, this, null, null,
                              new AccountManagerCallback<Bundle>()
    {
        public void run(AccountManagerFuture<Bundle> future) {
            try {
                Bundle bundle = future.getResult();
                System.out.println("Got Bundle:\n" +
                                   " act name: " +
                                   bundle.getString(AccountManager.KEY_ACCOUNT_NAME) +
                                   "\n act type: " +
                                   bundle.getString(AccountManager.KEY_ACCOUNT_TYPE) +
                                   "\n auth token: " +
                                   bundle.getString(AccountManager.KEY_AUTHTOKEN));
            } catch (Exception e) {
                System.out.println("getAuthTokenByFeatures() cancelled or failed:");
                e.printStackTrace();
            }
        }
    }, null);
    

    but you can apply the same idea to your code. You can then use the OAuth token with Google User Info API, as described in Using OAuth 2.0 for Login to verify the email and get the user’s name.

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

Sidebar

Related Questions

Hey guys. I'm not much of a programmer, but still need to do some
i'm not an iphone programmer, but this is my problem : i have the
This not a programming question but Most of the programmers using Eclipse should have
I am not a Fortran programmer (just a short experience), but I need to
I'm not a perl programmer but need to debug an error. I'm using the
I have a simple question (but I'm not a programmer...) On http://www.strahlen.org/index.htm I manually
This has been an ongoing struggle for me for the last four days. I
This problem has been bothering me for sometime now, I have not settled on
I am not matlab programmer but I need to create an interface using matlab!
Some might need it, some might not. All those extra feature help noobs to

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.