Firebase Google登录错误:com.google.android.gms.common.api.ApiException:10

时间:2019-02-25 07:53:10

标签: android firebase firebase-authentication android-googleapiclient

第一张图片:

enter image description here

第二张图片: enter image description here

这是我创建GoogleSignInOptions对象的代码。在requestIdToken参数中,我将Web客户端ID从我的应用程序的Firebase控制台中放入(检查第一个图像)。 但是我读了一篇文章,说应该在页面“ https://console.developers.google.com/apis/credentials?project=feisty-truth-232713&folder&organizationId(创建第二张图片)上创建Web客户端ID(创建第二个图像),所以我创建了一个新项目,并在Oath同意屏幕上获取了OAuth 2.0客户端ID。

所以基本上我已经尝试了两个客户端ID(第一张图片和第二张图片)

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(String.valueOf(R.string.google_default_web_client_id))
            .requestEmail()
            .build();

但是在下面的代码中,在检索google登录帐户时,出现了“ com.google.android.gms.common.api.ApiException:10”异常。谁能说出即时通讯出错了。我尝试回答“ Firebase UI authentication with google fails with message (code:10 message:10)”,但问题仍然存在。

 @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        //if the requestCode is the Google Sign In code that we defined at starting
        if (requestCode == RC_SIGN_IN) {

            //Getting the GoogleSignIn Task
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
                //Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = task.getResult(ApiException.class);
                //authenticating with firebase
                firebaseAuthWithGoogle(account);
            } catch (ApiException e) {
                Toast.makeText(LoginActivity.this, e.getMessage()+e.toString(), Toast.LENGTH_SHORT).show();
                Log.d(TAG, "onActivityResult: "+e.toString()+"  "+e.getLocalizedMessage());
            }
        }
    }

0 个答案:

没有答案