Obtain the Passkey Registration Status During Signup in Auth0 Actions

Overview

Determining whether a user registered a passkey during signup requires using the Post User Registration trigger in Auth0 Actions. Calling the Management API endpoint to get a list of authentication methods retrieves this status.

Applies To

  • Auth0
  • Actions
  • Post User Registration Trigger
  • Passkeys

Solution

How do Auth0 Actions retrieve the passkey registration status?

 

Retrieve the passkey registration status by calling the Management API within a Post User Registration Action using the provided code snippet.

  1. Call the Get a list of authentication methods endpoint in the Management API.
  2. Review the following example Action code to get the status:
exports.onExecutePostUserRegistration = async (event, api) => {
  const tokenResponse = await fetch(`https://{TENANT}/oauth/token`, {
    method: 'POST',
    body: new URLSearchParams({
      grant_type: 'client_credentials',
      client_id: event.secrets.CLIENT_ID,
      client_secret: event.secrets.CLIENT_SECRET,
      audience: 'https://{TENANT}/api/v2/',
    }),
  });
  const token = await tokenResponse.json();
  const accessToken = token.access_token;

  const authenticationMethodsResponse = await fetch(`https://{TENANT}/api/v2/users/${event.user.user_id}/authentication-methods`, {
    headers: {
      'Authorization': `Bearer ${accessToken}`,
    },
  });
  const authenticationMethods = await authenticationMethodsResponse.json();
  console.log(`Authentication methods: ${JSON.stringify(authenticationMethods)}`);
};

NOTE: The example code is for demonstration purposes and lacks error handling. Validate and test the code in a testing tenant before deploying it to a production environment.

Recommended content

No recommended content found...