Android google authentification userinfo.email不工作

Android google authentification userinfo.email不工作,android,android-2.3-gingerbread,google-authentication,Android,Android 2.3 Gingerbread,Google Authentication,我有一个奇怪的问题。我正在使用谷歌认证,这在android>3.x上运行 但我在三星Handle(android版本2.3.3)和userinfo.emailscope上进行了测试 oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email 但经过一些试验,我发现如何使它发挥作用。只需要交换作用域: oauth2:https://www.google

我有一个奇怪的问题。我正在使用谷歌认证,这在android>3.x上运行

但我在三星Handle(android版本2.3.3)和
userinfo.email
scope上进行了测试

oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
但经过一些试验,我发现如何使它发挥作用。只需要交换作用域:

oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
这在我升级到安卓2.3.5版本之前一直有效。在那之后,我无法获得具有抓取用户电子邮件权限的令牌。我试着只用电子邮件交换,但没有效果

我的代码:

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

    am.getAuthToken(account, SCOPE, null, this, new AccountManagerCallback<Bundle>() {
        public void run(AccountManagerFuture<Bundle> future) {
            try {
                Bundle result = future.getResult();                 
                String token = result.getString(AccountManager.KEY_AUTHTOKEN);
                Log.d(TAG, "Google tokenas: " + token);


                authWithToken("google", token); //here I get working token, but this token don't have rights to grab user email
            } catch (OperationCanceledException e) {
                unsuccess();
            } catch (AuthenticatorException e) {
                unsuccess();
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }, new Handler(new Handler.Callback() {

        public boolean handleMessage(Message msg) {
            Log.d(TAG, "on error: " + msg.what);
            return false;
        }

    }));
private static final String SCOPE=“oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email";
getAuthToken(account,SCOPE,null,this,new AccountManagerCallback()){
公共作废运行(AccountManagerFuture){
试一试{
Bundle result=future.getResult();
String token=result.getString(AccountManager.KEY\u AUTHTOKEN);
Log.d(标记“GoogleTokenas:”+token);
authWithToken(“google”,token);//这里我得到了工作令牌,但这个令牌没有获取用户电子邮件的权限
}捕捉(操作取消异常e){
不成功();
}捕获(认证异常e){
不成功();
e、 printStackTrace();
}捕获(IOE异常){
e、 printStackTrace();
}
}
},新处理程序(new Handler.Callback(){
公共布尔句柄消息(消息消息消息){
Log.d(标记“on error:+msg.what”);
返回false;
}
}));

这个方法在android 4.0.4和4.1.x上仍然有效。

我发现了这个问题。问题是缓存的访问令牌。Android不检查访问令牌验证。如果访问令牌无效,我只需清除缓存并重试身份验证:

        am.invalidateAuthToken("com.google", token);
        auth(lastAccount);