A question about firebase auth for authentication via phone number.
I was wondering if it was possible to link a "Phone Provider" to say a Google Auth Provider. There is no explicit mention of it in the docs.
The thing that had me scratching my head is - the Link Multiple Auth Provider docs talk about starting to authenticate with the new provider (phone provider) you want to link to the existing provider (google provider), but then stopping short of calling FirebaseAuth.signInWithXXX
.
So in theory that would work like:
FirebaseAuth.signInWithXXX
here, we can instead call FirebaseUser.linkWithCredential(PhoneAuthCredential)
.So i was wondering if a phone number verification is considered complete without an explicit sign-in with the PhoneAuthCredential
?
You can link a PhoneAuthCredential to an existing user, in your case, a user with a GoogleAuthProvider.
After you sign in the user with Google.
You then go through PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNumber, ...)
This would resolve with a PhoneAuthCredential or a verification ID. You can then ask for the SMS code and instantiate a PhoneAuthCredential via PhoneAuthProvider.getCredential
.
You can then link that credential to the currentUser: currentUser.linkWithCredential(phoneAuthCredential)