Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Phone Authentication Error: The SMS Code Has Expired

Having implemented the FireBase phone authentication as per the documentation, I get several problems.

  1. some numbers cannot be authenticated: I am using Airtel as my service provider.

On the log, I can confirm that the code has been sent but I haven't received it on my phone:

D/PhoneAuthenticating: onCodeSent:AM5PThBss5tbYdpNW5R9Q7o8zOYeHvd7lnZ1KBlS...

  1. Switching to another carrier, I can receive the code but then it says the SMS code has expired immediately after trying to verify. I make more attempts and result is the same

W/PhoneAuthenticating: signInWithCredential:failure com.google.firebase.auth.FirebaseAuthInvalidCredentialsException: The sms code has expired. Please re-send the verification code to try again. at com.google.android.gms.internal.nf.zzK(Unknown Source) at com.google.android.gms.internal.mg.zza(Unknown Source) at com.google.android.gms.internal.oa.zzL(Unknown Source) at com.google.android.gms.internal.oc.onFailure(Unknown Source) at com.google.android.gms.internal.nj.onTransact(Unknown Source) at android.os.Binder.execTransact(Binder.java:446)

This exception is thrown:

FirebaseAuthInvalidCredentialsException

code expiry takes more in than 3599 seconds in firebase. The time taken to verify is less than a minute

like image 925
Lucem Avatar asked Oct 02 '17 09:10

Lucem


People also ask

How do I remove Captcha verification from Firebase phone auth using Android?

Don't forget to go in Firebase Project Settings > App check > and Register firebase project in SafetyNet and Play Integrity register with default time token 1 hour and u will remove reCaptcha from phone auth OTP!

Is firebase SMS verification free?

Prices are per successful verification. On the Blaze plan, Phone Authentication provides a no-cost tier. The first 10K verifications for both instances (USA, Canada, and India and All other countries) are provided at no cost each month.


1 Answers

Just so that you know there's an auto retrieval section in firebase phone authentication which will read sms and invalidate it in the background. The callback for that auto-retrieval should be used to authenticate your user without him entering the sms manually.

like image 71
Vijay Kumar Kanta Avatar answered Oct 06 '22 13:10

Vijay Kumar Kanta