Google登录失败(ApiException:12501)

问题描述 投票:2回答:1

我正在尝试使用Google Play游戏登录。这是代码:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
            .requestServerAuthCode(getString(R.string.default_web_client_id))
            .build();

googleSignInClient = GoogleSignIn.getClient(this, gso);

我使用以下代码启动GoogleSignInActivity:

        @Override
        public void onClick(View view) {
            Intent intent = googleSignInClient.getSignInIntent();
            startActivityForResult(intent, SIGN_IN_CODE);
        }
    });

然后,它返回此处:

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

    if (requestCode == SIGN_IN_CODE){
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
            updateUI(null);
        }
    }
}

因此,在此行:

Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);

我收到此错误:

Google sign in failed: com.google.android.gms.common.api.ApiException: 12501

SHA1证书没有任何错误,因为我已多次生成它并将其粘贴到Firebase控制台中,而且我在清单文件中也具有此权限:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>

不推荐使用我的任何代码。我正在使用最新的依赖项:

implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'

我已经阅读了所有可能的文档。我对此感到非常绝望,几乎一个星期就遇到这个问题...

firebase android-studio google-play-services google-signin google-play-games
1个回答
0
投票

更改

GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN

GoogleSignInOptions.DEFAULT_SIGN_IN
© www.soinside.com 2019 - 2024. All rights reserved.