Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google plus Android Google Auth登录获取Id令牌handleSignInResult:false_Google Plus_Google Authenticator - Fatal编程技术网

Google plus Android Google Auth登录获取Id令牌handleSignInResult:false

Google plus Android Google Auth登录获取Id令牌handleSignInResult:false,google-plus,google-authenticator,Google Plus,Google Authenticator,我正在像这样设置GoogleSignations和GoogleAPI客户端 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.server_client_ID)) .build(); mGoogleApiClient = n

我正在像这样设置GoogleSignations和GoogleAPI客户端

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.server_client_ID))
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addApi(Plus.API)
            .build();
我的google web app客户端id如下:

 1020847812450-xxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
但总是在onActivityResult

    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }
返回值是假的吗

我在哪里做错了

启动段

    mGoogleApiClient.connect();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        // GoogleSignInResult result = opr.get();
        // handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.

        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {

                handleSignInResult(googleSignInResult);
            }
        });
    }
不可处理的结果

private void handleSignInResult(GoogleSignInResult result) {
    Log.e(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        final GoogleSignInAccount acct = result.getSignInAccount();
        Log.e(TAG, acct.getDisplayName());

    }
}

我相信您需要调用
client.connect()根据文档:


或者您的问题中缺少了它,而您正在调用
connect
som,代码中还有什么地方

我也面临同样的问题。首先删除当前的OAuth客户端ID,然后再创建一个OAuth客户端ID。这对我来说很有效。

您是否收到错误12501?我也有这个问题,因为我使用的是SDK附带的
debug.keystore
(由于我不知道的原因,它不起作用)。我自己创建了一个新的,从中得到了SHA-1散列,输入到GoogleAPI控制台,然后它工作了


确保您已设置。

按照所有步骤操作

Release APK和debug APK对于google服务具有不同的SHA1和API密钥。它们都必须添加到Firebase控制台->项目设置中。然后从这里下载google-services.json,将其添加到project中,并使用“Build signed APK”选项使用发布密钥库重新编译。这应该行得通

并且仔细阅读


您能否发布其余代码,尤其是呼叫和响应?
private void handleSignInResult(GoogleSignInResult result) {
    Log.e(TAG, "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        final GoogleSignInAccount acct = result.getSignInAccount();
        Log.e(TAG, acct.getDisplayName());

    }
}
GoogleApiClient client = new GoogleApiClient.Builder(this)
         .addApi(Plus.API)
         .addScope(Plus.SCOPE_PLUS_LOGIN)
         .setAccountName("users.account.name@gmail.com")
         .build();
 client.connect();