@digitalpersona/authentication
Version:
DigitalPersona Authentication API
34 lines (19 loc) • 1.35 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@digitalpersona/authentication](./authentication.md) > [SmsOtpAuth](./authentication.smsotpauth.md) > [authenticate](./authentication.smsotpauth.authenticate.md)
## SmsOtpAuth.authenticate() method
Authenticates the user using a challenge sent to the user's registered mobile device via SMS.
<b>Signature:</b>
```typescript
authenticate(identity: User | JSONWebToken, code: string): Promise<JSONWebToken>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| identity | <code>User | JSONWebToken</code> | a or a JSON Web Token. |
| code | <code>string</code> | a code the device user received via SMS challenge. |
<b>Returns:</b>
`Promise<JSONWebToken>`
a promise to return a JSON Web Token containing a claim (`crd`<!-- -->) showing the fact a OTP was used. Will reject if authentication fails.
## Remarks
If the `identity` parameter is a user name, a new token will be created. If the `identity` parameter is a JSON Web Token, an updated token will be returned.
The user must have a mobile device with a phone number registered in the DigitalPersona server. The user will receive an SMS on their mobile device and must type the code sent with the message.