How to customize access token generated by client credentials flow #3616
-
We plan to use backend server to generate access token for specific user. We don't want to use Authorization Code Flow. The preferred flow is "Client credential flow", When I check the doc: https://www.ory.sh/docs/oauth2-oidc/client-credentials, it seems that there are some limitations:
Is it possible to add cutomized field in access token? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @baominwang Yes, it is possible to add customized fields in the access token. This can be done by adding custom claims during the consent acceptance. Here's an example of how to do this:
In this example, some_custom_claim is added to every access token during consent acceptance. If you want some_custom_claim to be added to the top level (instead of a nested level) in the access token, you need to modify the /oauth2/allowed_top_level_claims configuration:
This results in an access token with the following structure:
Please note that required JWT claims can't be overwritten by custom claims. For more information, see the Ory documentation. |
Beta Was this translation helpful? Give feedback.
Hello @baominwang
Yes, it is possible to add customized fields in the access token. This can be done by adding custom claims during the consent acceptance. Here's an example of how to do this: