Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Android: An internal error has occurred. [ OPERATION_NOT_ALLOWED ]

Signing in via Google in my application gives this error:

An internal error has occurred. [ OPERATION_NOT_ALLOWED ]

I have enabled Google in the Firebase console. Permissions are correct, and I can't seem to find the problem. I'm sure this has nothing to do with my code, but if it does tell me.

SignInactivity:

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.sign_in_button:
            signIn();
            break;
    }
}

private void signIn() {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    startActivityForResult(signInIntent, RC_SIGN_IN);
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    // An unresolvable error has occurred and Google APIs (including Sign-In) will not
    // be available.
    Log.d(TAG, "onConnectionFailed:" + connectionResult);
    Toast.makeText(this, "Google Play Services error.", Toast.LENGTH_SHORT).show();
}

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

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed
            Log.e(TAG, "Google Sign In failed.");
        }
    }
}

private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.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(SignInActivity.this, "Authentication failed: " + task.getException(),
                       Toast.LENGTH_SHORT).show();
           } else {
               startActivity(new Intent(SignInActivity.this, MainActivity.class));
               finish();
           }
       }
    );
}
like image 207
Ali Bdeir Avatar asked Jun 14 '16 15:06

Ali Bdeir


3 Answers

I had the same problem. I got the solution in the forum post [Google Auth] com.google.firebase.FirebaseException: An internal error has occurred.

This happened to me when I did not have the authentication method enabled in the console Firebase. When I enabled Google authentication, I got the same exception, just without [OPERATION_NOT_ALLOWED].

like image 163
Ismael Junior Avatar answered Nov 20 '22 14:11

Ismael Junior


  1. Go to https://console.firebase.google.com/
  2. Select your project.
  3. Click on Authentication from menu option
  4. Click on SIGN-IN-METHOD
  5. Click on Google and enable it.

Than it works fine :)

like image 36
Dev Avatar answered Nov 20 '22 16:11

Dev


If you are signup with email and password then follow below steps.

Go to https://console.firebase.google.com/
Select your project.
Click on Authentication from menu option(Right-side menu)
Click on SIGN-IN-METHOD
Click on Email/Password and enable it.
Click on SAVE.
like image 2
ViramP Avatar answered Nov 20 '22 14:11

ViramP