本文介绍了Firebase Android:发生内部错误。 [OPERATION_NOT_ALLOWED]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

通过Google在我的应用程序中登录会出现以下错误:

Signing in via Google in my application gives this error:

我已经在Firebase控制台中启用了Google。权限是正确的,我似乎找不到问题。我确定这与我的代码无关,但如果它告诉我。

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:

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


推荐答案

我也有同样的问题。我在论坛帖子中获得了解决方案 。

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

当我在控制台Firebase中没有启用身份验证方法时,发生在我身上。当我启用Google身份验证时,我遇到了同样的异常,只是没有[OPERATION_NOT_ALLOWED]。

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].

这篇关于Firebase Android:发生内部错误。 [OPERATION_NOT_ALLOWED]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:36