UNPKG

veritatisdoloremque

Version:
54 lines (34 loc) 2.16 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/auth-types](./auth-types.md) &gt; [PhoneAuthProvider](./auth-types.phoneauthprovider.md) &gt; [verifyPhoneNumber](./auth-types.phoneauthprovider.verifyphonenumber.md) ## PhoneAuthProvider.verifyPhoneNumber() method Starts a phone number authentication flow by sending a verification code to the given phone number. <b>Signature:</b> ```typescript verifyPhoneNumber( phoneInfoOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier ): Promise<string>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | phoneInfoOptions | [PhoneInfoOptions](./auth-types.phoneinfooptions.md) \| string | The user's [PhoneInfoOptions](./auth-types.phoneinfooptions.md)<!-- -->. The phone number should be in E.164 format (e.g. +16505550101). | | applicationVerifier | [ApplicationVerifier](./auth-types.applicationverifier.md) | For abuse prevention, this method also requires a [ApplicationVerifier](./auth-types.applicationverifier.md)<!-- -->. This SDK includes a reCAPTCHA-based implementation, [RecaptchaVerifier](./auth-types.recaptchaverifier.md)<!-- -->. | <b>Returns:</b> Promise&lt;string&gt; A Promise for a verification ID that can be passed to [PhoneAuthProvider.credential()](./auth.phoneauthprovider.credential.md) to identify this flow.. ## Example 1 ```javascript const provider = new PhoneAuthProvider(auth); const verificationId = await provider.verifyPhoneNumber(phoneNumber, applicationVerifier); // Obtain verificationCode from the user. const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode); const userCredential = await signInWithCredential(auth, authCredential); ``` ## Example 2 An alternative flow is provided using the `signInWithPhoneNumber` method. ```javascript const confirmationResult = signInWithPhoneNumber(auth, phoneNumber, applicationVerifier); // Obtain verificationCode from the user. const userCredential = confirmationResult.confirm(verificationCode); ```