未找到Firebase在服务器配置中抛出OAuth2客户端ID [英] Firebase keeps throwing OAuth2 client id in server configuration is not found

查看:180
本文介绍了未找到Firebase在服务器配置中抛出OAuth2客户端ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Firebase将我的Google用户登录到我的应用程序,但每次使用下面的方法时,都会收到此错误:发生内部错误。 [未找到服务器配置中的OAuth2客户端ID。 ] 。我已经从开发人员控制台获取了我的客户端ID密钥,并且正在使用Web客户端ID,而不是我的请求令牌中的Android。任何想法?



这是我的代码:

  private void firebaseAuthWithGoogle (final GoogleSignInAccount acct){

final AuthCredential凭证= GoogleAuthProvider.getCredential(acct.getIdToken(),null);
mAuth.signInWithCredential(凭证)
.addOnCompleteListener(this,new OnCompleteListener< AuthResult>(){
@Override
public void onComplete(@NonNull Task< AuthResult> task){

$ b $ if(!task.isSuccessful()){

Toast.makeText(Login.this,糟糕,您的登录出了问题,请尝试,
Toast.LENGTH_SHORT).show();

}

else {


意图i = new Intent(Login.this,FindOpp.class);
startActivity(i);
}

}
});
}


解决方案

Firebase的默认配置使用服务.json从Firebase控制台(而不是云控制台)发出。在Firebase控制台上创建项目时,会自动配置Oauth设置,所以您不应使用您手动创建的任何其他键

在应用程序的模块根目录下拥有services.json应该是您需要调用 FirebaseAuth.signInWithCredential 的所有内容,而不需要手动设置Oauth设置。


I am trying to log my Google users into my app using Firebase, but every time I use the below method, I get this error: An internal error has occured. [ OAuth2 client id in server configuration is not found. ]. I have already gotten my client ID key from the developers console, and I am using the web client ID, not Android's in my request token. Any ideas?

Here is my code:

  private void firebaseAuthWithGoogle(final GoogleSignInAccount acct) {

        final AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {


                        if (!task.isSuccessful()) {

                            Toast.makeText(Login.this, "Oops, something went wrong with your login.  Please try again.",
                                    Toast.LENGTH_SHORT).show();

                        }

                        else{


                            Intent i = new Intent(Login.this, FindOpp.class);
                            startActivity(i);
                        }

                    }
                });
    }

解决方案

Firebase's default config uses the services.json issued from the firebase console (not the cloud console). The Oauth setting is configured automatically when you create the project on the Firebase console so you should NOT be using any other keys you manually created.

Having the services.json on your app's module root dir should be everything you need to call the FirebaseAuth.signInWithCredential no manual Oauth settings should be required.

这篇关于未找到Firebase在服务器配置中抛出OAuth2客户端ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆