1

我正在开发一个使用 Google 进行身份验证的 Android 应用程序。我们获取令牌以验证用户身份的代码如下,遵循“auth”示例 Android 项目的 GetNameInForeground.java:

/**
* 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;
}

登录时,我们经常收到错误“Unrecoverable error unknown”。这表明我们从调用 GoogleAuthUtil.getToken 中得到了 fatalExceptions,但我们不知道为什么。http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html没有提供太多有关错误消息的信息。

4

1 回答 1

0

当我不小心测试了一个使用 Temporary Eclipse Generated credentials 签名的二进制文件时,我看到了这个错误。我相信您需要使用用于在Google Play Console中生成服务器客户端 ID 的相同密钥对二进制文件进行签名。如果使用 Eclipse,请对应用程序进行签名导出并安装。

于 2013-05-21T20:07:15.633 回答