Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase keeps throwing OAuth2 client id in server configuration is not found

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);
                        }

                    }
                });
    }
like image 506
Jacob Platin Avatar asked Jun 20 '16 12:06

Jacob Platin


People also ask

How do I find my firebase client ID?

To find the OAuth 2.0 client ID: Open the Credentials page in the GCP Console. The Web application type client ID is your backend server's OAuth 2.0 client ID.

Does firebase use OAuth2?

Generate an access tokenThe Realtime Database REST API accepts standard Google OAuth2 access tokens. The access tokens can be generated using a service account with proper permissions to your Realtime Database.

What is an OAuth 2.0 client?

OAuth 2.0, which stands for “Open Authorization”, is a standard designed to allow a website or application to access resources hosted by other web apps on behalf of a user.


3 Answers

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.

like image 55
jirungaray Avatar answered Oct 17 '22 05:10

jirungaray


Here's a discussion which I found on Google Groups which was really helpful: https://groups.google.com/forum/?hl=ca#!topic/firebase-talk/d9MHQjAxFBY

I had to whitelist the Web client ID & Web client secret at https://console.developers.google.com/apis/credentials

Also make sure you are using requestIdToken(getString(R.string.default_web_client_id)) in the code instead of requestIdToken(<Actual Client ID>)

I hope this helps!

like image 40
Monu Surana Avatar answered Oct 17 '22 03:10

Monu Surana


jirungaray's answer is correct, you should not just generate your own keys in the API console. However, if you are like me and had deleted your keys while messing around, you can fix this situation.

In firebase go to Authentication -> Sign in Method -> Google -> Web SDK Configuration and here you can change the key and secret to the values you want.

like image 2
Greg Ennis Avatar answered Oct 17 '22 05:10

Greg Ennis