K
Kinde4mo ago
top kek

Adding org `handle` to the id token’s `organizations` array

I looked everywhere and can’t seem to figure it out! can someone help me? I’m sure it would be a custom workflow or something but there aren’t that many docs on the subject we can easily add an organizations array but they do not contain the org handles or external_ids
6 Replies
Roshan
Roshan4mo ago
Hi Freddie,

When you enable the Organizations (array) additional claim in ID token customization, you get organization id and name in this format:
"organizations": [
{
"id": "org_4ba6821b521",
"name": "ORG 1"
},
{
"id": "org_b7226a3b5f0",
"name": "ORG 2"
}
]
"organizations": [
{
"id": "org_4ba6821b521",
"name": "ORG 1"
},
{
"id": "org_b7226a3b5f0",
"name": "ORG 2"
}
]
- Use the Kinde Management API: After authentication, make API calls to retrieve full organization details including handles and external_ids for each organization the user belongs to. - Custom workflows: You could create a workflow that triggers during token generation to fetch and include additional organization metadata. Workflows allow you to customize tokens in ways not supported out of the box. Let me know if this helps, Thanks
top kek
top kekOP4mo ago
yeah im trying to add them to the token with custom workflows, it’s a little tough to grasp though! but im making progress I think it’s hard without type-safety and being able to try it before deploying it to kinde just calling this already breaks it
export default async function (event: onUserTokenGeneratedEvent) {
const kindeAPI = await createKindeAPI(event);
export default async function (event: onUserTokenGeneratedEvent) {
const kindeAPI = await createKindeAPI(event);
error parsing JSON from response: invalid character 'o' in literal null (expecting 'u') at github.com/kinde-oss/workflows-runtime/gojaRuntime.(*NativeModule).setupModuleForVM.(*NativeModule).setupModuleForVM.func2.func5 (native) at k (kindeknownpackage:https://cdn.jsdelivr.net/npm/@kinde/infrastructure@^0.4.1/+esm:7:2262(20)) at b (kindeknownpackage:https://cdn.jsdelivr.net/npm/@kinde/infrastructure@^0.4.1/+esm:7:3122(111)) at Workflow_default (../Workflow.ts:21:40(3))
error parsing JSON from response: invalid character 'o' in literal null (expecting 'u') at github.com/kinde-oss/workflows-runtime/gojaRuntime.(*NativeModule).setupModuleForVM.(*NativeModule).setupModuleForVM.func2.func5 (native) at k (kindeknownpackage:https://cdn.jsdelivr.net/npm/@kinde/infrastructure@^0.4.1/+esm:7:2262(20)) at b (kindeknownpackage:https://cdn.jsdelivr.net/npm/@kinde/infrastructure@^0.4.1/+esm:7:3122(111)) at Workflow_default (../Workflow.ts:21:40(3))
yes ive set the env variables right
Roshan
Roshan4mo ago
Hi, Freddie

The JSON parsing error suggests the token endpoint is returning an unexpected response, which usually indicates an authentication issue with the M2M application setup rather than the environment variables themselves.

Even with correct environment variables, this error typically occurs during the initial token exchange.

Here are the key troubleshooting steps: Required Environment Variables The createKindeAPI method looks for these specific environment variables: - KINDE_WF_M2M_CLIENT_ID - KINDE_WF_M2M_CLIENT_SECRET (ensure this is marked as sensitive) Required Bindings Make sure your workflow includes all necessary bindings
export const workflowSettings = {
id: "yourWorkflowId",
trigger: "user:tokens_generation",
bindings: {
"kinde.fetch": {},
"kinde.env": {},
"url": {}
}
};
export const workflowSettings = {
id: "yourWorkflowId",
trigger: "user:tokens_generation",
bindings: {
"kinde.fetch": {},
"kinde.env": {},
"url": {}
}
};
M2M Application Setup Verify your M2M application configuration: 1. The application must have access to the Kinde Management API 2. Grant the required scopes for your intended operations 3. Ensure the Client ID and Client Secret are correctly copied Let me know your result, hope it helps
Thanks
Abdiwak - Kinde
Abdiwak - Kinde3mo ago
Hey @freddie Just checking in to see how it's going with those troubleshooting steps. Any result? Let me know I any assistance needed. Thanks
top kek
top kekOP3mo ago
hi, i ended up relying on my db instead! thanks
Roshan
Roshan3mo ago
Thanks for the update, totally understandable!
If there is anything I can assist with, feel free to reach out. Always happy to assist.

Did you find this page helpful?