Home > @firebase/auth > PhoneAuthProvider
PhoneAuthProvider class
Provider for generating an PhoneAuthCredential.
Signature:
export declare class PhoneAuthProvider
Example
// 'recaptcha-container' is the ID of an element in the DOM.
const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
const provider = new PhoneAuthProvider(auth);
const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
// Obtain the verificationCode from the user.
const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
const userCredential = await signInWithCredential(auth, phoneCredential);
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(auth) | Constructs a new instance of the PhoneAuthProvider class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
PHONE_SIGN_IN_METHOD | static |
(not declared) | Always set to SignInMethod.PHONE. |
PROVIDER_ID | static |
(not declared) | Always set to ProviderId.PHONE. |
providerId | (not declared) | Always set to ProviderId.PHONE. |
Methods
Method | Modifiers | Description |
---|---|---|
credential(verificationId, verificationCode) | static |
Creates a phone auth credential, given the verification ID from PhoneAuthProvider.verifyPhoneNumber() and the code that was sent to the user's mobile device. |
credentialFromError(error) | static |
Returns an AuthCredential when passed an error. |
credentialFromResult(userCredential) | static |
Generates an AuthCredential from a UserCredential. |
verifyPhoneNumber(phoneOptions, applicationVerifier) | Starts a phone number authentication flow by sending a verification code to the given phone number. |