android - 如何在没有 Identity Toolkit API 的情况下使 Firebase 身份验证完全工作

标签 android firebase firebase-authentication android-studio-3.1

我正在尝试在 Android 项目中使用 Firebase 创建电子邮件密码帐户。 我使用 Android Studio 的 Firebase 助手添加了 Firebase。

创建用户代码如下。

mAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            FirebaseUser user = mAuth.getCurrentUser();
                            onLoginUpdateUI(user);
                        } else {
                            System.err.println("message:\n" + task.getException().getMessage());
                            onLoginUpdateUI(null);
                        }
                }
            });

我输入了有效的电子邮件和密码(超过 6 个字符)我收到以下错误:

com.google.firebase.FirebaseException: An internal error has occurred. [ Identity Toolkit API has not been used in project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project= then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. ]

我在 https://console.firebase.google.com 中启用了电子邮件/密码登录方法.

然后我去了https://console.developers.google.com并启用了 Identity Toolkit API。

然后身份验证工作正常。

但是我见过

The newest version of Google Identity Toolkit has been released as Firebase Authentication. Going forward, feature work on Identity Toolkit will be frozen and all new feature development will be done on Firebase Authentication. We encourage Identity Toolkit developers to move to Firebase Authentication as soon as is practical for their applications; however, Identity Toolkit continues to work and will not be deprecated without a further announcement.

所以我的问题是,如果他们打算弃用 Identity Toolkit API,如何在没有 Identity Toolkit API 的情况下完全进行 Firebase 电子邮件/密码身份验证?

最佳答案

我必须在 https://console.firebase.google.com 中手动创建一个新的 Firebase 项目(不使用 Android Studio 中的 Firebase 帮助)并将 google-services.json 替换为新的。它奏效了。

关于android - 如何在没有 Identity Toolkit API 的情况下使 Firebase 身份验证完全工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51133843/

相关文章:

ios - 在使用 Swift 的 iOS 应用程序中使用 DispatchQueue 等待数据从 Cloud Firestore 返回时遇到问题

ios - 使用共享的 iOS Keychain 启用跨应用程序 Firebase 身份验证

angular - 有条件地绕过 Auth0 HttpInterceptor

Firebase - 自定义 oAuth2 服务 - 授权代码?

android - 如何实现双短按和长按的Button?

android - 太多的字段引用 : 70613; max is 65536

android - android.location.LocationManager.PASSIVE_PROVIDER 是什么意思?

javascript - 在哪里使用 Sails.js 初始化和加载 map ?

android - 如何更改 lottie json 文件中的单个图像

java - 为什么 Facebook 登录无法在 Android 中的签名版本 APK 中工作?