2013-05-07 127 views
1

我正在使用Google进行身份验证的Android应用程序。我们用来获取令牌来验证用户的身份如下,继“身份验证”样品的Android项目的GetNameInForeground.java代码:Android:GoogleAuthUtil中的致命异常

/** 
* Get a authentication token if one is not available. If the error is not recoverable then 
* it displays the error message on parent activity right away. 
*/ 
@Override 
protected String fetchToken() throws IOException { 
    try { 
     return GoogleAuthUtil.getToken(mActivity, mEmail, mScope); 
    } catch (GooglePlayServicesAvailabilityException playEx) { 
     // GooglePlayServices.apk is either old, disabled, or not present. 
     mActivity.showErrorDialog(playEx.getConnectionStatusCode()); 
    } catch (UserRecoverableAuthException userRecoverableException) { 
     // Unable to authenticate, but the user can fix this. 
     // Forward the user to the appropriate activity. 
     onError("Authorization problem with Google account", userRecoverableException); 
     //mActivity.startActivityForResult(userRecoverableException.getIntent(), mRequestCode); 
    } catch (GoogleAuthException fatalException) { 
     onError("Unrecoverable error " + fatalException.getMessage(), fatalException); 
    } 
    return null; 
} 

登录时,我们经常收到错误消息“不可恢复的错误未知。”这表明我们正在调用GoogleAuthUtil.getToken而发生致命异常,但我们无法说明原因。 http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html没有提供有关错误消息的很多信息。

回答

0

我意外地测试了使用临时Eclipse生成凭据签名的二进制文件时看到了此错误。我相信你需要用Google Play Console中用于生成服务器客户端ID的相同密钥对二进制文件进行签名。如果使用Eclipse,请执行应用程序的签名导出并安装。

+0

从何时起,GoogleAuthUtil.getToken()方法开始针对未在设备上注册的电子邮件抛出一个带有消息“BadUsername”的GoogleAuthException,而不是以前的异常IllegalArgumentException带有消息“Non existing account'email_address'”? http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html#getToken(android.content.Context,java.lang.String中,java.lang.String中) – toobsco42 2013-11-06 02:31:02