[英]Android Firebase authentication issue
I'm trying to login with Firebase authentication but I'm getting a FirebaseException. 我正在尝试使用Firebase身份验证登录,但是却遇到了FirebaseException。 In my activity I have the onCreate method: 在我的活动中,我具有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();
}
The onStart method: onStart方法:
@Override
protected void onStart() {
super.onStart();
FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
// something
} else {
signIn();
}
}
and the signIn method: 和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);
}
});
}
I'm getting this: 我得到这个:
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)
the authentication method email, password is enabled on firebase console and also Identity Toolkit API. 在Firebase控制台以及Identity Toolkit API上启用了身份验证方法电子邮件,密码。
Please Check Your Project Existing firebase console using following URL https://console.firebase.google.com If is it available rebuild your project using Build -> Rebuild Project and Resync your project using Gradle Files 请使用以下网址检查您的项目现有的Firebase控制台https://console.firebase.google.com如果可用,请使用Build-> Rebuild Project并使用Gradle Files重新同步您的项目
Is your google-services.json file from Firebase up to date? Firebase上的google-services.json文件是否最新? As you enable services in Firebase that JSON gets updates. 在Firebase中启用服务时,JSON会更新。 Try re-downloading it from Firebase and check if it is different? 尝试从Firebase重新下载它,然后检查它是否不同?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.