Sign in after organisation selection

When the user signs in and needs to choose for a organisation. The claims in the token does not show which organisation the user had choosen. How do we need to find out what the user choose?
3 Replies
Ages - Kinde
Ages - Kinde6d ago
Hi, thanks for your question! When a user signs in and is associated with multiple organizations, Kinde provides tokens that include both the currently selected organization and a list of all organizations the user belongs to. Here’s how you can retrieve that information: ✅ Get the currently selected organization:
Use the getOrganization() helper method. It returns an object with the orgCode of the active organization the user chose during login:
await client.getOrganization();
// { orgCode: "org_1234" }
await client.getOrganization();
// { orgCode: "org_1234" }
Get all organizations the user belongs to:
Use getUserOrganizations(). This returns an array of all orgCodes the user is linked to:
await client.getUserOrganizations();
// { orgCodes: ["org_1234", "org_abcd"] }
await client.getUserOrganizations();
// { orgCodes: ["org_1234", "org_abcd"] }
You can also find these in the ID token, under the org_codes claim for the full list, and org_code for the current one. 🔄 Switching between organizations:
If you’d like to allow users to switch organizations within your app, you can implement an organization switcher using the login() method with the desired org_code. Full guide here:
🔗 Navigate between organizations Let me know if that helps, or if you'd like a hand setting it up!
Kinde docs
Build a switch to navigate between organizations
Our developer tools provide everything you need to get started with Kinde.
prullebakje.
prullebakje.OP5d ago
Thanks, but when i use the .NET SDK i get the followoing error when retrieving the organization: Error calling GetOrganization: {"errors": [{"code": "CODE_IS_REQUIRED", "message": "Code is required"}, {"code": "ORGANIZATION_INVALID", "message": "Invalid organization"}]} Example code:
var organizationsApi = new OrganizationsApi(client);
var organization = await organizationsApi.GetOrganizationAsync();
var organizationsApi = new OrganizationsApi(client);
var organization = await organizationsApi.GetOrganizationAsync();
See https://discord.com/channels/1070212618549219328/1364986715336347658
Ages - Kinde
Ages - Kinde5d ago
Thanks for sharing the link to the other thread — let’s continue the conversation there to keep everything in one place. Appreciate you flagging it!

Did you find this page helpful?