I'm trying to implement Firebase phone auth in my app.
I referred the firebase android documents on GitHub, but I can't get the code by SMS.
I don't know why it is happening? I'm testing it on a real device.
Also, I'm sending SMS to another one because the real device doesn't have a sim card. But I'm sure that it's not a problem. Is it right?
This is my code
void logIn(){
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verificaiton without
// user action.
Log.d("verification", "onVerificationCompleted:" + credential);
// [START_EXCLUDE silent]
mVerificationInProgress = false;
// [END_EXCLUDE]
// [START_EXCLUDE silent]
// Update the UI and attempt sign in with the phone credential
// [END_EXCLUDE]
signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Log.w("verification", "onVerificationFailed", e);
// [START_EXCLUDE silent]
mVerificationInProgress = false;
// [END_EXCLUDE]
if (e instanceof FirebaseAuthInvalidCredentialsException) {
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// [START_EXCLUDE]
Snackbar.make(findViewById(android.R.id.content), "Quota exceeded.",
Snackbar.LENGTH_SHORT).show();
// [END_EXCLUDE]
}
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d("verification", "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
}
};
PhoneAuthProvider.getInstance().verifyPhoneNumber(
"+79995198722", // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
mVerificationInProgress = true;
}
private void verifyPhoneNumberWithCode(String verificationId, String code) {
// [START verify_with_code]
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
// [END verify_with_code]
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, 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("signIn", "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
} else {
// Sign in failed, display a message and update the UI
Log.w("signIn", "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
}
}
}
});
}
Thanks in advance!
I think your problem might be SHA-1 finger print, So you need to update the SHA-1 key in Firebase console.
Steps:
After login to Firebase console
Click on your project then you can see Overview of your project
Click on 3 dots and click Settings
Click Add Finger print (At bottom)
Paste your SHA-1 key click on Save.
Steps to SHA-1 key:
Select gradle in Android Studio from left panel
Select your App
Go to Tasks -> android -> signingReport
then you can see the Sha-1 key.
I solved my problem by running an app on a real machine(Android Device) instead of an emulator.
Related
I have made an Android application using Firebase Phone Authentication and Realtime Database.
My requirement is to first check if the user's no. is in my database or not and then send him the OTP.
My database:
My code:
rootRef= FirebaseDatabase.getInstance().getReference().child("Employees").child("mobno");
//---------------1----------------
getcodeBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.d("abcd","get code button clicked");
if (!cugET.getText().toString().trim().isEmpty() && cugValidFlag==true) {
Log.d("abcd","entered no. is valid");
enteredcugno = cugET.getText().toString().trim();
Log.d("abcd","Entered cugno: "+enteredcugno);
rootRef.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.d("abcd","rootRef listener reached");
if(dataSnapshot.child(enteredcugno).exists()){
Log.d("abcd","cugno exists in db");
startPhoneNumberVerification(cugET.getText().toString().trim());
mVerified = false;
otpTV.setVisibility(View.VISIBLE);
otpET.setVisibility(View.VISIBLE);
otpValTV.setVisibility(View.VISIBLE);
verifycodeBtn.setVisibility(View.VISIBLE);
}
else{
Log.d("abcd","cugno doesn't exists in db");
Toast.makeText(cugLogin.this,"No such CUG No. found",Toast.LENGTH_SHORT).show();
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
});
//------------------------2--------------------
private void startPhoneNumberVerification(String phoneNumber) {
Log.d("abcd","startPhoneNumberVerification");
// [START start_phone_auth]
PhoneAuthProvider.getInstance().verifyPhoneNumber(
"+91"+phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
// [END start_phone_auth]
}
//--------------3--------------------
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verificaiton without
// user action.
Log.d("abcd", "onVerificationCompleted:" + credential);
signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Log.w("abcd", "onVerificationFailed", e);
if (e instanceof FirebaseAuthInvalidCredentialsException) {
Log.d("abcd","verification failed cz of FirebaseAuthInvalidCredentialsException");
Toast.makeText(cugLogin.this,"Verification Failed !! Invalied verification Code",Toast.LENGTH_SHORT).show();
}
else if (e instanceof FirebaseTooManyRequestsException) {
Log.d("abcd","verification failed cz FirebaseTooManyRequestsException");
Toast.makeText(cugLogin.this,"Verification Failed !! Too many request. Try after some time. ",Toast.LENGTH_SHORT);
}
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d("abcd", "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
}
};
//----------------4---------------
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
Log.d("abcd","signInWithPhoneAuthCredential reached");
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, 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("abcd", "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
mVerified = true;
timer.cancel();
timerTV.setVisibility(View.INVISIBLE);
cugET.setEnabled(false);
cugTV.setVisibility(View.INVISIBLE);
cugET.setVisibility(View.INVISIBLE);
getcodeBtn.setVisibility(View.INVISIBLE);
otpTV.setVisibility(View.INVISIBLE);
otpET.setVisibility(View.INVISIBLE);
otpValTV.setVisibility(View.INVISIBLE);
verifycodeBtn.setVisibility(View.INVISIBLE);
Intent intent = new Intent(cugLogin.this,Login.class);
intent.putExtra("cugnotoLogin",enteredcugno);
startActivity(intent);
Toast.makeText(cugLogin.this,"Successfully verified",Toast.LENGTH_SHORT).show();
// ...
} else {
// Sign in failed, display a message and update the UI
Log.w("abcd", "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
Toast.makeText(cugLogin.this,"Invalid OTP ! Please enter correct OTP",Toast.LENGTH_SHORT).show();
}
}
}
});
}
The last log I see is "Entered cugno: 9876543210"
No error being shown, I am really confused how can I correct it?
If I remove the rootRef listener my code is working but I want to check the user in the database first. Also I am giving the correct path to the rootRef then why isn't it working?
EDIT
I got my code working but I am still a bit confused, I just moved my rootRef initialization in the getcodeBtn listener. But I already had it in my onStart() function so it should have been initialized there as well, if anyone knows the reason behind it please let me know.
LATEST EDIT
Now when I signed out, my code is again stuck at the rootRef listener, it isn't getting passed into it. Even after closing the app it isn't letting me in. It's the same thing happening again. It's like something got refreshed overnight and the app let me sign in and when I signed out, I am stuck again. Why is this happening?
I solved it, it wasn't the coding problem but the logic was faulty. I set the rules of the database for the authenticated users only, and was checking my database first to let the user to sign in, so when I logged out, the code went into a loop as it couldn't access the database to let the user sign in.
I created an app in the android studio and linked it with Firebase Realtime database. I have used its Notifications service to send OTP to authenticate the user mobile no.
The problem I am facing is that after logout, I want to send OTP again to the number entered by the user but instead of that it is verifying the number and automatically opening the activity. Can anyone help me out ???
This method can send OTP to your Mo. number
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks);
You require call back to getting response
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verification without
// user action.
Log.d(TAG, "onVerificationCompleted:" + credential);
signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Log.w(TAG, "onVerificationFailed", e);
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
// Show a message and update the UI
// ...
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d(TAG, "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
// ...
}};
And for verification of OTP call below method
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, 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, "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
// ...
} else {
// Sign in failed, display a message and update the UI
Log.w(TAG, "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
}
}
}
});}
I am trying to test firebase phone auth for multiple devices, when I try with phones with android 5.0 or later, it works fine. For lower android api's I receive this message:
This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed. Is app running on a physical device? ]
This is my phone verification block
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verificaiton without
// user action.
Log.d(TAG, "onVerificationCompleted:" + credential);
Snackbar.make(findViewById(android.R.id.content), "Verification completed.",
Snackbar.LENGTH_SHORT).show();
spinner.setVisibility(View.GONE);
// [START_EXCLUDE silenst]
mVerificationInProgress = false;
// [END_EXCLUDE]
// [START_EXCLUDE silent]
// Update the UI and attempt sign in with the phone credential
//updateUI(STATE_VERIFY_SUCCESS, credential);
// [END_EXCLUDE]
//signInWithPhoneAuthCredential(credential);
deviceTokenCheck(phoneNumber);
}
#Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Log.w(TAG, "onVerificationFailed", e);
// [START_EXCLUDE silent]
mVerificationInProgress = false;
// [END_EXCLUDE]
spinner.setVisibility(View.GONE);
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// [START_EXCLUDE]
mPhoneNumberField.setError("Invalid phone number.");
// [END_EXCLUDE]
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// [START_EXCLUDE]
Snackbar.make(findViewById(android.R.id.content), "Quota exceeded.",
Snackbar.LENGTH_SHORT).show();
// [END_EXCLUDE]
}
// Show a message and update the UI
// [START_EXCLUDE]
updateUI(STATE_VERIFY_FAILED);
// [END_EXCLUDE]
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d(TAG, "onCodeSent:" + verificationId);
spinner.setVisibility(View.GONE);
Snackbar.make(findViewById(android.R.id.content), "Code Sent.",
Snackbar.LENGTH_SHORT).show();
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
// [START_EXCLUDE]
// Update UI
updateUI(STATE_CODE_SENT);
// [END_EXCLUDE]
}
};
// [END phone_auth_callbacks]
}
I have followed all the steps to configure phone auth for firebase but still, i am not able to get OTP from firebase.
Is it mandatory to link play store account to firebase for phone auth.
Please help !!!!!
Enable Phone auth in firebase Authentication SIGN-IN METHOD.
Past this code in onCreate Method.
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verificaiton without
// user action.
Log.d(TAG, "onVerificationCompleted:" + credential);
//signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Log.w(TAG, "onVerificationFailed", e);
Toast.makeText(SignUp.this, e.getMessage(), Toast.LENGTH_LONG).show();
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
// Show a message and update the UI
// ...
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d(TAG, "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
// ...
}
};
I turned off auto verification. User always have to input the code.
send code to user
String phoneNumber = phoneNumberET.getText().toString();
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
Take code from user and send it to verify
String code = mCodeEt.getText().toString();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, code);
signInWithPhoneAuthCredential(credential);
This method is result method
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, 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, "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
//Sucess do what u want to do
// [START_EXCLUDE]
//updateUI(STATE_SIGNIN_SUCCESS, user);
// [END_EXCLUDE]
} else {
// Sign in failed, display a message and update the UI
Log.w(TAG, "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
// [START_EXCLUDE silent]
mCodeEt.setError("Invalid code.");
// [END_EXCLUDE]
}
// [START_EXCLUDE silent]
// Update UI
//updateUI(STATE_SIGNIN_FAILED);
// [END_EXCLUDE]
}
}
});
}
All code taken from firebase doc....
I have implemented two step authentication in my app using firebase authentication in which I have used gmail, facebook or simple email login for authenticating. As digits phone verification has migrated to firebase i have implemented firebase phone authentication by linking the existing logged in account (facebook, gmail, or email) with phone authentication credentials. It works fine when used with facebook and email account. When user is logged in through google and tries to verify mobile through phone authentication this logs are printed :
signInWithCredential:failure
com.google.firebase.auth.FirebaseAuthUserCollisionException: An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.
Read this article. Is it the same issue as mentioned in the article?? Is there any solution for the same..
After research over internet and in firebase documentation itself I found solution to this two step authentication in app using firebase auth.
firebaseAuth.getCurrentUser().updatePhoneNumber(credential).addOnCompleteListener(this, new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "signInWithCredential:success");
Snackbar.make(findViewById(android.R.id.content), "Mobile Verified Successfully.",
Snackbar.LENGTH_SHORT).show();
} else {
Log.w(TAG, "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
//mVerificationField.setError("Invalid code.");
Snackbar.make(findViewById(android.R.id.content), "Invalid Code.",
Snackbar.LENGTH_SHORT).show();
} else {
Toast.makeText(context,"signInWithCredential:failure"+task.getException(),
Snackbar.LENGTH_LONG).show();
}
}
}
});
Just pass the PhoneAuthCredential to above method and it will verify the phone assigns to your existing account. Make sure it is not used by any other account.
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
now phone auth is available in firebase.Here is Code for Phone Auth using Firebase:
If there is any question fee free to ASK me.
EditText phoneNum,Code; //// two edit text one for enter phone number other for enter OTP code
Button sent_,Verify; // sent_ button to request for verification and verify is for to verify code
private PhoneAuthProvider.ForceResendingToken mResendToken;
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
private FirebaseAuth mAuth;
private String mVerificationId;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_phone_number_auth);
phoneNum =(EditText) findViewById(R.id.fn_num);
Code =(EditText) findViewById(R.id.code);
sent_ =(Button)findViewById(R.id.sent_nu);
Verify =(Button)findViewById(R.id.verify);
callback_verificvation();
mAuth = FirebaseAuth.getInstance();
sent_.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String num=phoneNum.getText().toString();
startPhoneNumberVerification(num); // call function for receive OTP 6 digit code
}
});
Verify.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String code=Code.getText().toString();
verifyPhoneNumberWithCode(mVerificationId,code); //call function for verify code
}
});
}
private void startPhoneNumberVerification(String phoneNumber) {
// [START start_phone_auth]
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
// [END start_phone_auth]
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, 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
FirebaseUser user = task.getResult().getUser();
Toast.makeText(getApplicationContext(), "sign in successfull", Toast.LENGTH_SHORT).show();
// [START_EXCLUDE]
// [END_EXCLUDE]
} else {
// Sign in failed, display a message and update the UI
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
// [START_EXCLUDE silent]
// [END_EXCLUDE]
}
// [START_EXCLUDE silent]
// Update UI
// [END_EXCLUDE]
}
}
});
}
private void verifyPhoneNumberWithCode(String verificationId, String code) {
// [START verify_with_code]
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
// [END verify_with_code]
signInWithPhoneAuthCredential(credential);
}
private void callback_verificvation() {
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
}
};
This Exception is thrown because you have connected the email pw login and facebook login together, the google account with same email used in facebook one's is not associated together. As by default, firebase doesn't allow multiple account from same email this collision occurs.
To solve this issue you have two options
1. Link the google account to the facebook and email one's using
mAuth.getCurrentUser().linkWithCredential(credential);
Adding new credential to the existing logged in user.
2. Enable multiple account from same email(not recommended) from the firebase console
This will make new uid for the google logged user and the previous facebook login user will have the old one.