Skip to content
  • Workflows
  • Bindings

kinde.accessToken

The kinde.accessToken binding lets you modify access tokens for the current user. When you add custom claims, they are included in the access token returned to the client.

setCustomClaim(name: string, value: any): void

Link to this section

Adds a custom claim to the access token. The claim will be available when the token is returned to the client.

Available in workflows

Link to this section
export const workflowSettings = {
// ...other settings
bindings: {"kinde.accessToken": {}}
};
Link to this section

The Kinde infrastructure library provides type-safe access token modification:

import { accessTokenCustomClaims } from "@kinde/infrastructure";
export default async function (event: onUserTokenGeneratedEvent) {
const accessToken = accessTokenCustomClaims<{
hello: string;
ipAddress: string;
}>();
accessToken.hello = "Hello there!";
accessToken.ipAddress = event.request.ip;
};

Using the low-level API

Link to this section

If you’re not using the infrastructure library, you can modify the access token directly:

kinde.accessToken.setCustomClaim("hello", "Hello there!");
kinde.accessToken.setCustomClaim("ipAddress", event.request.ip);