M2Mトリガー
M2Mトリガーは、アクセストークンがクライアントの資格情報フローで発行された場合に実行されます。

このフロー内のアクションはブロッキング(同期的)であり、トリガーのプロセスの一部として実行されます。そのため、アクションが完了するまでAuth0パイプラインの他の部分の実行が停止されます。
トリガー
M2M / クライアント資格情報
credentials-exchange
トリガーは、アクセストークンが返される前に実行される関数です。
リファレンス
イベントオブジェクト:クライアント資格情報交換の要求についてコンテキスト情報を提供します。
APIオブジェクト:フローの動作を変更するためのメソッドが提供されます。
一般的なユースケース
アクセス制御
credentials-exchangeアクションは、カスタムロジックに基づいてアクセストークンを拒否するのに使用できます。
/**
* @param {Event} event - Details about client credentials grant request.
* @param {CredentialsExchangeAPI} api - Interface whose methods can be used to change the behavior of client credentials grant.
*/
exports.onExecuteCredentialsExchange = async (event, api) => {
if (event.request.geoip.continentCode === "NA") {
api.access.deny('invalid_request', "Access from North America is not allowed.");
}
};
Was this helpful?
/
アクセストークンにカスタムクレームを追加する
credentials-exchangeアクションは、アクセストークンにカスタムクレームを追加するのに使用できます。
/**
* @param {Event} event - Details about client credentials grant request.
* @param {CredentialsExchangeAPI} api - Interface whose methods can be used to change the behavior of client credentials grant.
*/
exports.onExecuteCredentialsExchange = async (event, api) => {
api.accessToken.setCustomClaim("https://my-api.exampleco.com/request-ip", event.request.ip);
};
Was this helpful?
/