Auth0

Auth0 is an identity-as-a-service (IDaaS) platform that offers authentication and authorization solutions for applications, allowing developers to easily implement features such as single sign-on (SSO), passwordless login, and multi-factor authentication (MFA) without developing the infrastructure themselves. Acquired by Okta in 2021, Auth0 provides a secure, customizable platform for user login and access management, handling sensitive data and security standards like OAuth 2.0.

Prerequisites

Usage

  1. Open the Auth0 dashboard and navigate to Actions->Library->Create Action.

  2. Enter a meaningful name and select the appropriate trigger—in this example, we will use the Send Phone Message trigger.

    Create action
  3. Click Create to create the action. We start by creating a secret for our API key by clicking Add Secret.

    Create secret

    Now we paste the code below into the editor:

        exports.onExecuteSendPhoneMessage = async (event, api) => {
          const { code, text, recipient: to } = event.message_options;
          const body = { text: `${text}\n${code}`, to }
          const response = await fetch('https://gateway.seven.io/api/sms', {
            method: 'POST',
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/json',
              'X-Api-Key': event.secrets['SEVEN_API_KEY']
            },
            body: JSON.stringify(body)
          });
    
          console.log(response.status); // 200
          const json = await response.json()
          console.log(json)
          return json
        };
    
    Overview of our custom action
  4. Now we can test the action by clicking on the Play button and then on Run.