Closed kisanzxy closed 5 years ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
@kisanzxy does this happen every time you create a new user? What are the steps to reproduce this?
@samstern This happens only on the Android phone. And yes, it happens every time I create a new user on the android device. However, it works fine on the emulator. I use the sample code to test on a device and it happened.
@kisanzxy can you please provide the code that causes this issue? And what is the phone model? What version of Google Play services (settings --> apps --> Google Play services) is running on the phone?
@samtstern Google play services version 16.0.89
And for the code. Could I email you or invite you as a collaborator?
@kisanzxy please just provide a small snippet of code here where the problem occurs, we can't look at or debug your whole project.
@samtstern This is where the bug might be; it always goes into the else branch and prints out " CreateAccount Authentication failed." and the Firebase console didn't update But we can create new user successfully everytime when testing on the emulator
And there is a snippet of the Gradle file
project level
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
app level
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-auth:16.2.0'
}
private void createAccount(String email, String password) {
Log.d(TAG, "createAccount:" + email);
if (!validateForm()) {
return;
}
// [START create_user_with_email]
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "createUserWithEmail:success");
Toast.makeText(getActivity(), "CreateAccount Success.",
Toast.LENGTH_SHORT).show();
FirebaseUser user = mAuth.getCurrentUser();
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.getException());
Toast.makeText(getActivity(), "CreateAccount Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
// [END create_user_with_email]
}
@malcolmdeck any idea what might cause a simple createUserWithEmailAndPassword
to return a 400 error? The device has latest GmsCore (16.0.089) and the code works on an emulator, which is the opposite of the problem people normally have.
+Leonardo Siracusa leosiracusa@google.com
This looks new to me. Leo, any ideas?
On Tue, Apr 2, 2019, 9:03 AM Sam Stern notifications@github.com wrote:
@malcolmdeck https://github.com/malcolmdeck any idea what might cause a simple createUserWithEmailAndPassword to return a 400 error? The device has latest GmsCore (16.0.089) and the code works on an emulator, which is the opposite of the problem people normally have.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-android-sdk/issues/330#issuecomment-479069019, or mute the thread https://github.com/notifications/unsubscribe-auth/AWl8K97b8PfLFDoOIovWdf0pNgBziJS8ks5vc39ngaJpZM4cW9HG .
What exception is it failing with?
@samtstern HI, I feel so sorry to report this bug. The only reason that we cannot create a new user is that when typing in the email, there is a single space added to the end. So the auth failed because of the bad format error after we look into the full error message. However, the error message only printed out half part " CreateAccount Authentication failed.". It's really hard to notice this tiny " " at the end of the email string.
This thread can be closed
@kisanzxy thanks for telling us!
@lsirac can we maybe have the backend trim
some inputs?
[READ] Step 1: Are you in the right place?
Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
E/Volley: [2672] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?alt=proto&key=api-key
Error occurs when creating a new user
Steps to reproduce:
What happened? How can we make the problem occur? testing on an Android device, but no error when using an emulator This could be a description, log/console output, etc.
Relevant Code: