简体   繁体   中英

Firebase email and password authentication fails

Firebase email and password authentication fails even though I have it activated in the Firebase console and the code for that activity is from the github sample.

Also I have added a user manually so everything is there.

I am doing as in this link describes: Firebase instructions

Update

Here is the code for the signing in method:

mAuth.signInWithEmailAndPassword(email, password)
     .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
          Log.d(TAG, "signInWithEmail: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, "signInWithEmail", task.getException());
            Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
            Toast.LENGTH_SHORT).show();
          }

          // [START_EXCLUDE]
          hideProgressDialog();
          // [END_EXCLUDE]
        }
      });

Update 2

I have also tried to do this and I does not work either:

private void signInBeta(String email,String password){
  Firebase ref = new Firebase("https://prechecker-46a58.firebaseio.com/");

  ref.authWithPassword(String.valueOf(email), String.valueOf(password), new Firebase.AuthResultHandler() {
    @Override
    public void onAuthenticated(AuthData authData) {
      System.out.println("User ID: " + authData.getUid() + ", Provider: " + authData.getProvider());
    }

    @Override
    public void onAuthenticationError(FirebaseError firebaseError) {
      System.out.print("\nSOMETING WENT WRONG\n");
    }
  });
}

This could be because you haven't enable oAuth for login.
Try adding OAuth Client ID in https://console.developers.google.com/apis/credentials ?

Firebase does not accept if the email id is not in the format of email id and it does not accept password with shorter length. My Problem is also the same, but the solution might seems sense less to you. I hope this may helps you. While giving email and password make sure that email id has '@domain.com' for example 'leoXXXX@gmail.com' and your password must atleast has length of 10.

如果您使用虚拟设备运行应用程序,请检查Google服务是否为最新版本,或切换到包含所有更新的个人设备。

If you are using an emulator please use the latest device, because older than Pixel XL devices won't work, You will get an error message as: "Authentication failed." including Pixel XL.

我花了整整一天的时间来弄清楚,事实证明您需要密码长度为6+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM