メインコンテンツへスキップ
customized-consent 画面は、カスタマイズされた同意エクスペリエンスを使用するアプリケーションに対して、ユーザーが権限の許可または拒否を求められる際に、認可フロー中に表示されます。要求されたスコープが表示され、ユーザーは同意リクエストを承認または拒否できます。
ACUL Customized Consent

インポート

各画面には、それぞれ専用のフックとメソッドが用意されています。SDK は、各画面で部分インポートルートインポートをサポートしています。
  • 部分インポートを使用すると、特定のユースケースに必要なコードだけを取り込めます。
  • ルートインポートを使用すると、単一のバンドルからすべての画面を読み込めます。これは、1 つの統一ビルドですべての画面パターンに対応したい場合に便利です。
Import Example
// ルートインポート
import { useCustomizedConsent } from '@auth0/auth0-acul-react';

// 部分インポート
import {
  useCustomizedConsent,
  // コンテキストフック
  useUser,
  useTenant,
  useBranding,
  useClient,
  useOrganization,
  usePrompt,
  useScreen,
  useTransaction,
  useUntrustedData,
  // 共通フック
  useCurrentScreen,
  useAuth0Themes,
  useErrors,
  // ユーティリティフック
  useChangeLanguage,
  // メソッド
  accept,
  deny,
} from '@auth0/auth0-acul-react/customized-consent';

function CustomizedConsentScreen() {
  const { accept, deny } = useCustomizedConsent();
  return (
    <>
      <button onClick={() => accept()}>Accept</button>
      <button onClick={() => deny()}>Deny</button>
    </>
  );
}

コンテキストフック

customized-consent 画面で Auth0 のコンテキストデータへの読み取り専用アクセスを提供する、画面スコープのフックです。@auth0/auth0-acul-react/customized-consent からインポートします。
useBranding
このフックは、customized-consent 画面に表示されるロゴ、色、テーマ設定などのブランディング設定を提供します。
Example
import { useBranding } from '@auth0/auth0-acul-react/customized-consent';
function CustomTheme() {
  const branding = useBranding();
}
useClient
このフックは、customized-consent 画面の idnamelogoUrl など、クライアント関連の設定を提供します。
Example
import { useClient } from '@auth0/auth0-acul-react/customized-consent';
function AppInfo() {
  const client = useClient();
}
useOrganization
このフックは、同意リクエストが組織スコープの場合に、ユーザーの組織に関する情報を提供します。組織コンテキストが存在しない場合は null を返します。
Example
import { useOrganization } from '@auth0/auth0-acul-react/customized-consent';
function OrgSelector() {
  const organization = useOrganization();
  if (!organization) {
    return <p>No Organization context</p>;
  }
}
usePrompt
このフックには、認証フロー内の現在のプロンプトに関するデータが含まれます。
Example
import { usePrompt } from '@auth0/auth0-acul-react/customized-consent';
function FlowInfo() {
  const prompt = usePrompt();
}
このフックには、設定やコンテキストなど、customized-consent 画面に固有の詳細が含まれます。
Example
import { useScreen } from '@auth0/auth0-acul-react/customized-consent';
function ScreenDebug() {
  const screen = useScreen();
}
useTenant
このフックには、id や関連するメタデータなど、テナントに関するデータが含まれます。
Example
import { useTenant } from '@auth0/auth0-acul-react/customized-consent';
function TenantInfo() {
  const tenant = useTenant();
}
useTransaction
このフックは、アクティブな接続や現在のフロー状態など、customized-consent 画面のトランザクション固有のデータを提供します。
Example
import { useTransaction } from '@auth0/auth0-acul-react/customized-consent';
function TransactionInfo() {
  const transaction = useTransaction();
}
useUntrustedData
このフックは、URL クエリ文字列から事前入力されたパラメーターなど、画面に渡される信頼できないデータを扱います。
Example
import { useUntrustedData } from '@auth0/auth0-acul-react/customized-consent';
function PrefilledForm() {
  const untrustedData = useUntrustedData();
}
useUser
このフックは、アクティブなユーザーに関する詳細情報 (usernameemail、利用可能な認証方法など) を提供します。
Example
import { useUser } from '@auth0/auth0-acul-react/customized-consent';
function UserProfile() {
  const user = useUser();
}
このフックは、customized-consent 画面で利用できるすべてのメソッドとコンテキストを返します。

メソッド

accept
Promise<void>
このメソッドは、ユーザーの同意を送信し、要求された権限をアプリケーションに付与します。
Example
import { useCustomizedConsent } from '@auth0/auth0-acul-react/customized-consent';

function AcceptButton() {
  const { accept } = useCustomizedConsent();
  return (
    <button onClick={() => accept()}>
      Accept
    </button>
  );
}
deny
Promise<void>
このメソッドは、同意リクエストを拒否し、要求された権限をアプリケーションから取り消します。
Example
import { useCustomizedConsent } from '@auth0/auth0-acul-react/customized-consent';

function DenyButton() {
  const { deny } = useCustomizedConsent();
  return (
    <button onClick={() => deny()}>
      Deny
    </button>
  );
}

共通/ユーティリティ フック

このフックは、ブランディングコンテキストからフラット化された設定を含む現在のテーマオプションを取得します。
このフックは、現在の ACUL 画面の表示言語を変更する関数を返します。
このフックは、現在の画面のコンテキストと状態を取得します。
このフックは、画面上のサーバー、クライアント、開発者のエラーを読み取り、管理します。