0

The below code snippet produces an invalid auth_token (verified through https://accounts.google.com/o/oauth2/tokeninfo?access_token=) when run on android 2.3.

The only way to get AccountManager return the valid one is to manually go through account settings and remove than add an existing google account. When rerun the token will be valid until not expired, than the same issue reappears. Note that the problem is not occurring on devices with android 4.0 and higher.

Can you please assist in sorting this out?

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

accountManager.getAuthToken(googleAccountsMap.get(accountName), SCOPE, null, getActivity(),
                    new OnAuthTokenAcquired(), null);   


private class OnAuthTokenAcquired implements AccountManagerCallback<Bundle> {

    @Override
    public void run(AccountManagerFuture<Bundle> result) {
        try {
            Bundle bundle = result.getResult(); 
            String accountName = bundle.getString(AccountManager.KEY_ACCOUNT_NAME);
            String authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
quirkfly
  • 121
  • 1
  • 5
  • Try reboot your device and then add Google account to it. – AndroidHacker Dec 05 '13 at 09:18
  • Yeah this would most likely rectify the issue, however only temporarily. Moreover reboot is not an option an end-user would retreat to unless having no other choice. – quirkfly Dec 05 '13 at 12:56

1 Answers1

0

The issue has been resolved. For those experiencing similar symptoms below link describes the solution

AccountManager: invalidateAuthToken does not invalidate the token

Community
  • 1
  • 1
quirkfly
  • 121
  • 1
  • 5