Adding custom claims to M2M tokens
Custom claims allow you to encode additional information into your Stytch M2M access tokens, similar to session custom claims.
How to use
First, pass in extra parameters to the Get Access Token API endpoint. For example, to add a custom user_id claim:
{
"client_id": "m2m-client-test-cxxxxxx",
"client_secret": "xxxxxx",
"grant_type": "client_credentials",
"user_id": "123"
}Most backend SDKs also support this via the extra param in the corresponding method.
Next, create a M2M custom claims template, either via the Dashboard or the API and include this claim using the variable syntax request.[claim]:
{
"user_id": {{ request.user_id }}
}You should see your custom user_id claim in newly minted M2M tokens.