Sign In Options

You can customize the Digits for Web sign in flow to collect user email addresses or pre-fill phone number information, based on your app’s needs.

Access Email Addresses

Digits can be configured to collect the user’s email address as an additional step after a successful phone number authentication.

/* Launch the Login to Digits flow and access the user's email address */
function onLoginButtonClick(event){
  Digits.logIn({
    accountFields: Digits.AccountFields.Email
  })
    .done(onLogin) /*handle the response*/
    .fail(onLoginFailure);
}

Email Verification

The user’s email address is available on the Digits session object returned in the OAuth Echo object and can be accessed through the email_address.address property property.

After the user submits the email screen, they will receive an email from Digits asking to confirm their email address. You can check on whether the email address has been confirmed through the email_address.is_verified property.

Provide a Phone Number

Digits for Web exposes an API to allow configuration options such as a default phone number to be passed into the authentication flow. Use -.logIn() and include a phone number on the passed configuration object, with optional country code. Digits will attempt to parse out the country code and prepopulate both the country selector and phone number field. Note: the ‘+’ character is required for country code parsing:

/* Launch the Login to Digits flow and access the user's email address */
function onLoginButtonClick(event){
  Digits.logIn({
    phoneNumber: '+527835555555'
  })
    .done(onLogin) /*handle the response*/
    .fail(onLoginFailure);
}

Prefill the Country Code

Digits for Web allows prefilling of just the country code field if there’s a default country that makes sense for your app. By default, the country picker uses the user’s Headers in determining which country to use. This can be changed by launching Digits with -.logIn() and including only the country code in the configuration object.

/* Launch the Login to Digits flow and access the user's email address */
function onLoginButtonClick(event){
  Digits.logIn({
    phoneNumber: '+52'
  })
    .done(onLogin) /*handle the response*/
    .fail(onLoginFailure);
}

Callback URL

Optional navigation flow instead of relying on pop-ups and window.postMessage. If you pass a callback URL the SDK will navigate to digits.com and when finished, redirect back to that URL. The Echo Header and Service URL will be passed as parameters to the callback.

Note: For security, the domain of this callback URL must match the domain of the “website” URL registered for your app in https://www.fabric.io.

/* Launch the Login to Digits flow and access the user's email address */
function onLoginButtonClick(event){
  Digits.logIn({
    callbackURL: 'https://www.myapp.com/digits_callback'
  })
}