简体   繁体   English

在Android 2.3上运行时,AccountManager返回无效的auth_token

[英]AccountManager returns invalid auth_token when run on android 2.3

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. 在Android 2.3上运行时,以下代码段会生成无效的auth_token (通过https://accounts.google.com/o/oauth2/tokeninfo?access_token=进行验证)。

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. 使AccountManager返回有效帐户的唯一方法是手动进行帐户设置,然后删除而不是添加现有的Google帐户。 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. 请注意,在具有Android 4.0及更高版本的设备上不会发生此问题。

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);

The issue has been resolved. 该问题已解决。 For those experiencing similar symptoms below link describes the solution 对于那些遇到类似症状的人,下面的链接描述了解决方案

AccountManager: invalidateAuthToken does not invalidate the token AccountManager:invalidateAuthToken不会使令牌无效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM