Failed to register using firebase auth module

Our requirement

Email / password registration with Firebase SDK on android

Problem

The onComplete () method is not called. An error / exception is not thrown. Note. We have enabled the email / password provider in the Firebase console.

Please find the code below -

public void onClick(View v) { try { if (v == saveView) { String email = emailView.getText().toString(); String password = passwordView.getText().toString(); if (validate(email, password)) { mAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "createUserWithEmail: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()) { Toast.makeText(UserRegisterActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); } } }catch (Exception e) { Log.d("BIG", e.getStackTrace().toString()); } } private boolean validate(String email , String password){ return true; } 
+5
source share
2 answers

Try it, work with me, maybe it will help you

  firebase.createUser(etEmail.getText().toString(), etPassword.getText().toString(), new Firebase.ValueResultHandler<Map<String, Object>>() { @Override public void onSuccess(Map<String, Object> result) { System.out.println("Successfully created user account with uid: " + result.get("uid")); } @Override public void onError(FirebaseError firebaseError) { // there was an error String errorMessage = firebaseError.getMessage(); Toast.makeText(RegisterActivity.this, ""+errorMessage, Toast.LENGTH_SHORT).show(); } }); 

To enter

  firebase.authWithPassword(etEmail.getText().toString(), etPassword.getText().toString(), new Firebase.AuthResultHandler() { @Override public void onAuthenticated(AuthData authData) { Log.e(TAG, "User Authenticated"); System.out.println("User ID: " + authData.getUid() + ", Provider: " + authData.getProvider()); } @Override public void onAuthenticationError(FirebaseError firebaseError) { switch (firebaseError.getCode()) { case FirebaseError.USER_DOES_NOT_EXIST: // handle a non existing user Log.e(TAG, "User Does Not Exist"); break; case FirebaseError.INVALID_PASSWORD: // handle an invalid password Log.e(TAG, "Invalid Password"); break; default: // handle other errors break; } } }); 
0
source

For the old Firebase API . Try

 fbRoot.authWithPassword("email", "pasw", new Firebase.AuthResultHandler() { @Override public void onAuthenticated(AuthData authData) { Toast.makeText(MainActivity.this, "User ID: " + authData.getUid() + ", Provider: " + authData.getProvider(), Toast.LENGTH_SHORT).show(); } @Override public void onAuthenticationError(FirebaseError firebaseError) { } }); 

And this is for creating an account.

 fbRoot.createUser("email", "password", new Firebase.ResultHandler() { @Override public void onSuccess() { Toast.makeText(MainActivity.this, "Saved", Toast.LENGTH_SHORT).show(); } @Override public void onError(FirebaseError firebaseError) { Toast.makeText(MainActivity.this, firebaseError.getMessage(), Toast.LENGTH_SHORT).show(); } }); 
0
source

All Articles