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);
}
}
});
}
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.
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.
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.
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.
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With