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沒有提供有關錯誤消息的很多信息。
從何時起,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