> ## Documentation Index
> Fetch the complete documentation index at: https://translations.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Auth0 の Authorization Extension を使用して、Rules により API へのユーザーアクセスを拒否する方法を説明します。

# Rules を使用して API へのユーザーアクセスを拒否する

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  Auth0 の Authorization Extension でのみ使用できます。Authorization Core feature set を使用している場合は、代わりに[組み込みのトークンダイアレクト](/ja/docs/get-started/apis/enable-role-based-access-control-for-apis#token-dialect-options)を使用してください。詳しくは、[Authorization Core と Authorization Extension の比較](/ja/docs/manage-users/access-control/authorization-core-vs-authorization-extension)を参照してください。
</Callout>

[Dashboard > Auth0 Pipeline > Rules](https://manage.auth0.com/#/rules) に移動します。[Rules](/ja/docs/customize/rules) は、ユーザー管理からユーザープロフィールの拡張まで、さまざまな目的に使用できます。ユーザーの API へのアクセスを拒否する必要がある場合は、スコープが割り当てられたロールを作成し、次に <Tooltip tip="アクセストークン: API へのアクセスに使用される、不透明な文字列または JWT 形式の認可資格情報。" cta="用語集を表示" href="/ja/docs/glossary?term=Access+Token">アクセストークン</Tooltip> からスコープを削除する Rule を作成できます。

```javascript lines theme={null}
{
function (user, context, callback) {
  var permissions = user.permissions || [];
  var requestedScopes = context.request.body.scope || context.request.query.scope;
  var filteredScopes = requestedScopes.split(' ').filter( function(x) {
      return x.indexOf(':') < 0;
  });

  var allScopes = filteredScopes.concat(permissions);
  context.accessToken.scope = allScopes.join(' ');

  callback(null, user, context);
}
```
