【问题标题】:Android Firebase authentication issueAndroid Firebase 身份验证问题
【发布时间】:2018-10-12 00:25:18
【问题描述】:

我正在尝试使用 Firebase 身份验证登录,但我收到了 FirebaseException。在我的活动中,我有 onCreate 方法:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mAuth = FirebaseAuth.getInstance();
        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        actionBar.setTitle(R.string.title_calendar);
        initData();

    }

onStart 方法:

@Override
    protected void onStart() {
        super.onStart();

        FirebaseUser user = mAuth.getCurrentUser();
        if (user != null) {
            // something
        } else {
            signIn();
        }
    }

以及登录方法:

private void signIn() {
        mAuth.signInWithEmailAndPassword("test@abc.com", "123456789").addOnSuccessListener(this, new  OnSuccessListener<AuthResult>() {
            @Override
            public void onSuccess(AuthResult authResult) {
                Log.i("Log", "signIn:SUCCESS");
            }
        })
                .addOnFailureListener(this, new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception exception) {
                        Log.e("Log", "signIn:FAILURE", exception);
                    }
                });
    }

我明白了:

E/shinseiLog: signIn:FAILURE
    com.google.firebase.FirebaseException: An internal error has occurred. [ Identity Toolkit API has not been used in project 611854850952 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=611854850952 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. ]
        at com.google.android.gms.internal.jz.zzK(Unknown Source:147)
        at com.google.android.gms.internal.jb.zza(Unknown Source:12)
        at com.google.android.gms.internal.kj.zzL(Unknown Source:11)
        at com.google.android.gms.internal.kl.onFailure(Unknown Source:35)
        at com.google.android.gms.internal.kb.onTransact(Unknown Source:79)
        at android.os.Binder.execTransact(Binder.java:697)

身份验证方法电子邮件、密码已在 firebase 控制台和 Identity Toolkit API 上启用。

【问题讨论】:

  • 你用过android studio的fire base assistant吗??
  • 该错误表明您尚未启用使用此方法登录。您必须首先在 firebase 中转到您的项目并打开您尝试登录的方法。

标签: android firebase firebase-authentication


【解决方案1】:

请使用以下 URL 检查您的项目现有的 firebase 控制台 https://console.firebase.google.com 如果它可用重建你的项目使用 构建 -> 重建项目 并使用 Gradle 文件重新同步您的项目

Sync With GradleFiles Icon

【讨论】:

  • 谢谢,所有身份验证方法都已启用。重建后认证成功。
  • 欢迎您!很高兴
【解决方案2】:

您来自 Firebase 的 google-services.json 文件是最新的吗?当您在 Firebase 中启用服务时,JSON 会得到更新。尝试从 Firebase 重新下载并检查是否不同?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-16
    • 2021-12-09
    • 2021-04-21
    • 2020-12-22
    • 2020-11-27
    • 2020-04-18
    相关资源
    最近更新 更多