DjHacktorReborn
DjHacktorReborn

Reputation: 2928

Android Firebase Google SIgnon bad request

Android Firebase Google signin through authorization error when google return token id. i have both cleint id as well as web sdk key saved on firebase. Even json file.

 AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                        // If sign in fails, display a message to the user. If sign in succeeds
                        // the auth state listener will be notified and logic to handle the
                        // signed in user can be handled in the listener.
                        if (!task.isSuccessful()) {
                            Log.w(TAG, "signInWithCredential", task.getException());
                            Toast.makeText(OnBoarding.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                        // ...
                    }
                });

Got this error

com.google.firebase.FirebaseException: An internal error has occured. [ Bad Request ]
                                                                          at com.google.android.gms.internal.zzacq.zzbN(Unknown Source)
                                                                          at com.google.android.gms.internal.zzacn$zzg.zza(Unknown Source)
                                                                          at com.google.android.gms.internal.zzacy.zzbO(Unknown Source)
                                                                          at com.google.android.gms.internal.zzacy$zza.onFailure(Unknown Source)
                                                                          at com.google.android.gms.internal.zzact$zza.onTransact(Unknown Source)
                                                                          at android.os.Binder.execTransact(Binder.java:565)

Though google signIn went well there is something missing with firebase which m not able to figure out need help

Logs

"error": {
    "errors": [{
        "domain": "usageLimits",
        "reason": "keyExpired",
        "message": "Bad Request"
    }],
    "code": 400,
    "message": "Bad Request"
}

                                                   }

Upvotes: 4

Views: 3132

Answers (2)

GuyA
GuyA

Reputation: 197

In the firebase console (Overview) Under Your mobile apps click the overflow button (three vertical dots) and goto Manage.

Once there goto your app and download the google-services.json

Add that to the root directory of your app and also to the /app folder.

This worked for me to fix this exact error. I assume I changed something at some point and needed a new one.

Hopefully this helps. Goodluck

Upvotes: 7

pRaNaY
pRaNaY

Reputation: 25310

Some reason to get [ Bad Request ].

Error Conditions:

The Firebase REST API will return error codes under these circumstances.

1) 404 Not Found : A request made over HTTP instead of HTTPS

2) 400 Bad Request : Unable to parse PUT or POST data

3) 400 Bad Request : Missing PUT or POST data

4) 400 Bad Request : Attempting to PUT or POST data which is too large

5) 417 Expectation Failed : A REST API call that doesn't specify a Firebase name

6) 400 Bad Request : A REST API call that contains invalid child names as part of the path

7) 403 Forbidden : A request that violates your Security and Firebase Rules

Check which type of parameter or other things are missing in request as per above option.

I hope its helps you.

Upvotes: 0

Related Questions