gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 23:27:41 27 4
gpt4 key购买 nike

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

An internal error has occurred. [ OPERATION_NOT_ALLOWED ]

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

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

最佳答案

我遇到了同样的问题。我在论坛帖子中得到了解决方案 [Google Auth] com.google.firebase.FirebaseException: An internal error has occurred .

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

关于android - Firebase Android : An internal error has occurred. [OPERATION_NOT_ALLOWED],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37816014/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com