0D5WR00002NPFNc0APOkta Classic EngineAuthenticationAnswered2026-11-06T16:05:12.000Z2026-11-02T06:32:34.000Z2026-11-06T16:05:12.000Z

JoeM.36848 (Customer) asked a question.

Custom ID token claim set to "Userinfo / id_token request" still included in ID token (Authorization Code + PKCE, Identity Engine)

I'm trying to return a custom claim only from /userinfo and keep it out of the ID token, using a custom authorization server in an Identity Engine org.

 

Docs say this should work

 

Create API access claims (https://help.okta.com/oie/en-us/content/topics/security/api-config-claims.htm):

  • ID token claims are dynamic. By default, the authorization server doesn't include them in the ID token when requested with an access token or authorization code. To keep this default, select Userinfo/id_token request for Include in token type… If the claim isn't included, the client must use an access token to get the claims from the UserInfo endpoint.

 

Authorization Server Claims API (https://developer.okta.com/docs/api/openapi/okta-management/management/tag/AuthorizationServerClaims) (alwaysIncludeInToken):

  • If the value is set to FALSE for an ID token claim, the Claim isn't included in the ID token when the token is requested with the access token or with the authorization_code.

 

OpenID Connect & OAuth 2.0 overview (https://developer.okta.com/docs/api/openapi/okta-oauth/guides/overview):

  • The /userinfo endpoint always contains a full set of claims for the requested scopes.

 

Setup

- Custom authorization server: default

- Custom scope: pii

- Custom claim: pii_claim

 - Include in token type: ID Token, Userinfo / id_token request

 - Value: user.email

 - Include in: scope pii

- App: SPA, Authorization Code + PKCE (okta-auth-js 7.14), Implicit not enabled

- Requested scopes: openid pii

 

Expected: pii_claim is absent from the ID token and returned by /userinfo.

 

Actual: pii_claim is present in both the ID token and /userinfo.

 

Already ruled out

- response_type is code (confirmed in the System Log app.oauth2.as.authorize event)

- An access token is issued alongside the ID token (the ID token contains at_hash)

- Only one claim definition named pii_claim exists; it isn't set to "Always"

- The issuer is the custom server (…/oauth2/default), not the org authorization server

- Token Preview (grant type Authorization Code, scopes openid pii) also shows pii_claim in the ID token, so it isn't client-side

 

Questions

1. Is this expected on Identity Engine, or a defect?

2. If expected, what's the supported way to return a claim only from /userinfo? Is a token inline hook removing it from the ID token the only option?


  • Paul S. (Okta, Inc.)

    Hello @JoeM.36848 (Customer)​ Thank you for posting on our Community page!

     

    You are asking how to configure a Custom Claim in a custom Authorization Server (default) on Identity Engine so that the claim pii_claim is returned only from the /userinfo endpoint and is absent from the ID token, and whether a Token Inline Hook is the only way to achieve this.

     

    Summary: The claim's ID token inclusion is controlled by the claim's alwaysIncludeInToken setting, so the first step is to confirm that setting is saved as false, and if it is, the claim should be removed from the ID token; if the claim still appears, that needs verification through Okta Support.

     

    Root Cause: The ID token contents for a custom claim depend on the claim's "Include in token type" setting. When that setting is "Userinfo/id_token request" (alwaysIncludeInToken=false), the claim is supposed to be left out of the ID token for an authorization code request, and the client is expected to retrieve it from /userinfo. Because pii_claim still appears in the ID token and in the Token Preview, the saved configuration does not match what the server issues, and this needs to be verified against the org.

     

    Solution: Follow these steps:

    1. Confirm the stored value by calling GET /api/v1/authorizationServers/{authServerId}/claims/{claimId} for pii_claim and checking that alwaysIncludeInToken is false. The Admin Console UI can show a saved setting that differs from the API representation, so this check is the authoritative one.
    2. Recreate the claim if the stored value is true or unexpected. Create a new claim with the same name, value user.email, Include in scope pii, and alwaysIncludeInToken set to false, then delete the old claim. Only one claim with the name pii_claim should exist on the server.
    3. Request a new token with the same client, scopes (openid pii), and grant type, then decode the ID token to confirm whether pii_claim is present. Request a fresh authorization code, since existing tokens do not reflect configuration changes.
    4. Call /oauth2/default/v1/userinfo with the access token and confirm pii_claim is returned.
    5. Use a Token Inline Hook if the ID token still includes the claim after steps 1 through 4. A Token Inline Hook can modify the claims in the ID token, so it is a supported way to exclude a claim from the ID token while keeping it on the access token and /userinfo response. Verify the exact hook command syntax in the current Okta documentation before implementing it.
    6. Open an Okta Support case if the ID token still contains pii_claim after the stored value is confirmed as false. Include the authorization server ID, the claim ID, the org URL, the authorize request time, and the System Log event ID for the token request so Support can check the server-side behavior.

     

     

    Thank you for reaching out to our Community and have a great day!

    --

    Help others in the community by liking or hitting Select as Best if this response helped you.

    Expand Post
    Selected as Best
  • Paul S. (Okta, Inc.)

    Hello @JoeM.36848 (Customer)​ Thank you for posting on our Community page!

     

    You are asking how to configure a Custom Claim in a custom Authorization Server (default) on Identity Engine so that the claim pii_claim is returned only from the /userinfo endpoint and is absent from the ID token, and whether a Token Inline Hook is the only way to achieve this.

     

    Summary: The claim's ID token inclusion is controlled by the claim's alwaysIncludeInToken setting, so the first step is to confirm that setting is saved as false, and if it is, the claim should be removed from the ID token; if the claim still appears, that needs verification through Okta Support.

     

    Root Cause: The ID token contents for a custom claim depend on the claim's "Include in token type" setting. When that setting is "Userinfo/id_token request" (alwaysIncludeInToken=false), the claim is supposed to be left out of the ID token for an authorization code request, and the client is expected to retrieve it from /userinfo. Because pii_claim still appears in the ID token and in the Token Preview, the saved configuration does not match what the server issues, and this needs to be verified against the org.

     

    Solution: Follow these steps:

    1. Confirm the stored value by calling GET /api/v1/authorizationServers/{authServerId}/claims/{claimId} for pii_claim and checking that alwaysIncludeInToken is false. The Admin Console UI can show a saved setting that differs from the API representation, so this check is the authoritative one.
    2. Recreate the claim if the stored value is true or unexpected. Create a new claim with the same name, value user.email, Include in scope pii, and alwaysIncludeInToken set to false, then delete the old claim. Only one claim with the name pii_claim should exist on the server.
    3. Request a new token with the same client, scopes (openid pii), and grant type, then decode the ID token to confirm whether pii_claim is present. Request a fresh authorization code, since existing tokens do not reflect configuration changes.
    4. Call /oauth2/default/v1/userinfo with the access token and confirm pii_claim is returned.
    5. Use a Token Inline Hook if the ID token still includes the claim after steps 1 through 4. A Token Inline Hook can modify the claims in the ID token, so it is a supported way to exclude a claim from the ID token while keeping it on the access token and /userinfo response. Verify the exact hook command syntax in the current Okta documentation before implementing it.
    6. Open an Okta Support case if the ID token still contains pii_claim after the stored value is confirmed as false. Include the authorization server ID, the claim ID, the org URL, the authorize request time, and the System Log event ID for the token request so Support can check the server-side behavior.

     

     

    Thank you for reaching out to our Community and have a great day!

    --

    Help others in the community by liking or hitting Select as Best if this response helped you.

    Expand Post
    Selected as Best

Recommended content

No recommended content found...