Skip to content

Files

Latest commit

2c13b36 · Jan 16, 2025

History

History
19 lines (14 loc) · 1016 Bytes

_api-auth-customize-tokens.md

File metadata and controls

19 lines (14 loc) · 1016 Bytes

You can use Rules to change the returned scopes of the Access Token and/or add claims to it (and the ID Token) with a script like this:

function(user, context, callback) {

  // add custom claims to Access Token and ID Token
  context.accessToken['http://foo/bar'] = 'value';
  context.idToken['http://fiz/baz'] = 'some other value';

  // change scope
  context.accessToken.scope = ['array', 'of', 'strings'];

  callback(null, user, context);
}

::: panel-warning Namespacing Custom Claims Auth0 returns profile information in a structured claim format as defined by the OpenID Connect (OIDC) specification. This means that in order to add custom claims to ID Tokens or Access Tokens, they must conform to a namespaced format to avoid possible collisions with standard OIDC claims. You can add namespaced claims using Rules. :::