PasswordlessAuthenticator

auth. PasswordlessAuthenticator

Handles authenticator with passwordless flows, e.g. SMS, Touch ID, etc.

Constructor

new PasswordlessAuthenticator(options, oauth)

Parameters:
Name Type Description
options Object Authenticator options.
Properties
Name Type Attributes Description
baseUrl String The auth0 account URL.
clientId String <optional>
Default client ID.
oauth OAuthAuthenticator OAuthAuthenticator instance.
Source:

Methods

sendEmail(userData, cbopt) → {Promise|undefined}

Start passwordless flow sending an email.
Parameters:
Name Type Attributes Description
userData Object User account data.
Properties
Name Type Description
email String User email address.
send String The type of email to be sent.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Example

Given the user `email` address, it will send an email with:

  • A link (default, `send:"link"`). You can then authenticate with this user opening the link and he will be automatically logged in to the application. Optionally, you can append/override parameters to the link (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using `authParams` object.
  • A verification code (`send:"code"`). You can then authenticate with this user using the `/oauth/ro` endpoint specifying `email` as `username` and `code` as `password`.
Find more information in the API Docs

var data = {
  email: '{EMAIL}',
  send: 'link',
  authParams: {} // Optional auth params.
};

auth0.passwordless.sendEmail(data, function (err) {
  if (err) {
    // Handle error.
  }
});

sendSMS(userData, cbopt) → {Promise|undefined}

Start passwordless flow sending an SMS.
Parameters:
Name Type Attributes Description
userData Object User account data.
Properties
Name Type Attributes Description
phone_number String User phone number.
client_id String <optional>
Client ID.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Example

Given the user `phone_number`, it will send a SMS message with a verification code. You can then authenticate with this user using the `/oauth/ro` endpoint specifying `phone_number` as `username` and `code` as `password`:

var data = {
  phone_number: '{PHONE}'
};

auth0.passwordless.sendSMS(data, function (err) {
  if (err) {
    // Handle error.
  }
});

signIn(userData, cbopt) → {Promise|undefined}

Sign in with the given user credentials.
Parameters:
Name Type Attributes Description
userData Object User credentials object.
Properties
Name Type Attributes Description
username String Username.
password String Password.
client_id String <optional>
Client ID.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Examples

Given the user credentials (`phone_number` and `code`), it will do the authentication on the provider and return a JSON with the `access_token` and `id_token`.

var data = {
  username: '{PHONE_NUMBER}',
  password: '{VERIFICATION_CODE}'
};

auth0.passwordless.signIn(data, function (err) {
  if (err) {
    // Handle error.
  }
});

The user data object has the following structure.

{
  id_token: String,
  access_token: String,
  token_type: String
}