firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

Firebase Auth get VerificationId

Open sinka49 opened this issue 5 years ago • 4 comments
trafficstars

please tell me how can I get the verificationId, after onCodeSent method called from firebase, to pass it to the method Firebase.auth.signInWithCredential(authCredential = PhoneAuthProvider().credential("??", "smsCode")) if automatic authorization did not work for some reason?

On the first screen of authorization I call PhoneAuthProvider().verifyPhoneNumber(phone, phoneVerificationProvider). If automatic authorization did not work I need to pass verificationId and smsCode manually to the signInWithCredential, but I cannot find how can I get verificationId

sinka49 avatar Nov 15 '20 23:11 sinka49

@Daeda88 do we need to expose extra APs for this?

nbransby avatar Dec 11 '20 18:12 nbransby

@nbransby I think yes, because the user only has a callback to send the SMS code again. It should look something like this:

override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) {
                verificationProvider.codeSent(**verificationId**) { android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) }
            }

heckslam avatar Dec 15 '20 17:12 heckslam

Iirc, the PhoneVerificationProvider intterface should have a suspend function that returns the verificationId. Implementing the interface allows you to respond. But looking t it now, it probably needs some changes to work properly.

Note that each platform handles verification very differently and as such it difficult to actually unify the behaviour.

Daeda88 avatar Dec 15 '20 19:12 Daeda88

override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) { verificationProvider.codeSent(**verificationId**) { android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) } }

What was mentioned above is needed for Android. This would allow the saving of the verificationId for manually calling the 2nd exposed api method.

verificationProvider.codeSent(verificationId) is needed

AKnght avatar Apr 08 '23 22:04 AKnght