Google登录-onActivityResult-resultCode始终等于0(RESULT_CANCELED)

时间:2020-04-17 22:59:24

标签: android webview google-play-services google-signin google-authentication

我正在集成Android的Google登录,并且我希望返回id_token以便可以通过服务器进行身份验证。我遵循了https://developers.google.com/identity/sign-in/android/backend-auth

中的所有步骤

问题在于onActivityResult()的结果代码为0

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

private void signIn() {
    Intent signInIntent = mGoogleSignInClient.getSignInIntent();
    startActivityForResult(signInIntent, RC_SIGN_IN);
}

onActivityResult:

    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "data : " + resultCode + " | " + data  + " || " + RC_SIGN_IN + " ||| " + requestCode);

你知道为什么resultCode总是等于0(RESULT_CANCELED)吗?

0 个答案:

没有答案