Send Language Preference for Passwordless SMS and Email using the Passwordless API with Auth0 SDKs

Overview

The article explains how to send language preferences for the sent passwordless SMS and passwordless Email messages using the passwordless API (/passwordless/start) using Auth0s SDKs.

Applies To

  • Language Preferences
  • Passwordless SMS and Email
  • Auth0 SDK

Solution

Auth0 supports language customization in Email and SMS passwordless templates with the /passwordless/start endpoint when the language preference is set with the x-request-language header. The language preference sent with this header is accessible in the template with the request_language keyword.

The template usage is documented for Email passwordless as well as SMS passwordless.

Some of the Auth0 SDKs support sending this header. The parameter to send the header may be different for different SDKs.

Auth0.js library

Pass the preferred language using the xRequestLanguage attribute.

webAuth.passwordlessStart({
    connection: 'email',
    send: 'code',
    email: 'foo@bar.com'
    xRequestLanguage: 'tr'
  }, function (err,res) {
    // handle errors or continue
  }
);

Node.js SDK

Pass the preferred language using the requestLanguage attribute.

await auth.passwordless.sendEmail({
    email: '{user email}',
    send: 'code',
  }, 
  {
    requestLanguage: 'tr'
  }
);

TIP: Search the x-request-language header in the Auth0 SDK source code to determine if it supports it.

E.g., Code search results · GitHub