Skip to main content
The CustomizedConsent class implements the customized-consent screen functionality. This screen prompts the user to accept or deny the permissions and authorization details requested by a client application.

Constructors

Create an instance of CustomizedConsent screen manager
Example
// How to use the CustomizedConsent screen SDK:
import CustomizedConsent from '@auth0/auth0-acul-js/customized-consent';

// Instantiate the manager for the customized consent screen
const consentManager = new CustomizedConsent();

// Accessing screen data
const clientName = consentManager.client.name;
const userEmail = consentManager.user.email;
const requestedScopes = consentManager.screen.scopes;
const authorizationDetails = consentManager.screen.authorizationDetails;

console.log(`${clientName} is requesting consent from ${userEmail}.`);
console.log("Requested Scopes:", requestedScopes);
console.log("Authorization Details:", authorizationDetails);

// Accessing transaction errors from a previous attempt
const transactionErrors = consentManager.transaction.errors;
if (transactionErrors && transactionErrors.length > 0) {
  transactionErrors.forEach(error => {
    console.error(`Error: ${error.message}`);
    // Display these errors to the user.
  });
}

// Example of handling consent acceptance
async function onAcceptConsent() {
  try {
    await consentManager.accept();
    // On success, Auth0 will typically redirect.
  } catch (e) {
    console.error('Failed to accept consent:', e);
  }
}

// Example of handling consent denial
async function onDenyConsent() {
  try {
    await consentManager.deny({ denial_reason: "user_declined" });
    // On success, Auth0 will typically redirect.
  } catch (e) {
    console.error('Failed to deny consent:', e);
  }
}

Properties

Provides branding-related configurations, such as branding theme and settings.
Provides client-related configurations, such as id, name, and logoUrl, for the customized-consent screen.
Provides information about the user’s organization, such as organization id and name.
Contains data about the current prompt in the authentication flow.
Contains details specific to the customized-consent screen, including scopes and authorizationDetails.
Contains data related to the tenant, such as id and associated metadata.
Provides transaction-specific data for the customized-consent screen, such as active identifiers and flow states.
Handles untrusted data passed to the SDK, such as user input during the consent flow.
Details of the active user, including username, email, and roles.

Methods

accept
(options ?)
This method submits the user’s decision to accept the requested permissions and authorization details.
Example
import CustomizedConsent from '@auth0/auth0-acul-js/customized-consent';

const consentManager = new CustomizedConsent();
async function onAcceptConsent() {
  try {
    await consentManager.accept();
    // On success, Auth0 will typically redirect.
  } catch (e) {
    console.error('Failed to accept consent:', e);
  }
}
options
OPTIONAL
Optional payload.
deny
(options ?)
This method submits the user’s decision to deny the requested permissions and authorization details.
Example
import CustomizedConsent from '@auth0/auth0-acul-js/customized-consent';

const consentManager = new CustomizedConsent();
async function onDenyConsent() {
  try {
    await consentManager.deny({ denial_reason: "user_declined" });
    // On success, Auth0 will typically redirect.
  } catch (e) {
    console.error('Failed to deny consent:', e);
  }
}
options
OPTIONAL
Optional payload.
getErrors
This method retrieves the array of transaction errors from the context, or an empty array if none exist.