Hello @AndyNugroho,
It seems like your claims mapping policy is applied correctly, as evidenced by the successful inclusion of the DisplayName claim (JWTCLAIM2) in the access token. The issue seems to be with the extrainfo claim not appearing likely stems from how Entra ID handles directory extensions in the context of client credentials flow. Specifically, while the directory extension is defined on the Resource App and set on the Client App, the client credentials flow operates under the context of the Client App’s service principal, not its application object. Directory extensions are stored in servicePrincipal or application objects in Entra ID. In the client credentials flow, the token is issued to the calling application (ClientApp). Claims mapping policy works on the service principal context. Only values present on the servicePrincipal are accessible, not on the application object by default. Directory extensions must be explicitly declared in the schema and synced properly. Entra ID only exposes claims that are present on the service principal when issuing access tokens in app-only flows.
Therefore, to have the extension_<resource_app_id>_extrainfo value included in the token, you need to ensure that this extension attribute is actually set on the Client App's service principal, not just the application. Check if the extension attribute exists on the ClientApp’s service principal and has the defined attribute if not set the value using PATCH command in MS graph. Once the extension attribute is correctly populated on the service principal, and your claims mapping policy includes the appropriate reference to the extension ID, the access token will correctly contain the desired extrainfo claim. Additionally, make sure this claims mapping policy is assigned to the Resource App’s service principal, as it is the API resource issuing the token.
If you have any questions, please do let us know.