Access Token claims not updating after "Refresh User Claims and Invalidate Cache"

Hi, I'm currently building a custom user onboarding flow with a multistep form and calling one of my API path. Within my application settings under Tokens, I have customized the access token with additional claims including Organization Name. Within this path, below are the high level actions being performed: 1. Invoke the API path with the Access token (Bearer token) 2. Validate the token using Kinde JWK 3. Check if the JWT token contains the key org_code 4. If no, then make multiple calls to the Kinde management API to create an organization, add feature flags to the organization, add the user to the organization with an owner role/permissions and then Refresh User Claims and Invalidate Cache. 5. On successful response from my API, reload the app to get a fresh access token with the org details in it. 6. If yes, it means the user has previosuly created an organization so redirect to the dashboard of the app. On app reload, I can see the organization information showing in the output of useKindeAuth's getUserOrganizations() but the org keys org_code from the additional claims in the access token is missing. getPermissions() and getOrganization() also return null values. When I log out and login, the claims get updated in the access token. how can I get the claims updated in the access token without having to logout and login ? I'm using the Kinde React SDK. Thanks
3 Replies
TotalScrub
TotalScrub2w ago
Hi, this thread might help you: https://discord.com/channels/1070212618549219328/1320557296593403904/1320557296593403904 Or this GitHub issue - https://github.com/kinde-oss/kinde-typescript-sdk/issues/63 I suspect what you need to do is log the user in with an org-code (no need to log them out) and if you use prompt = none then they won't visually see the Kinde UI (assuming they have a valid session)
GitHub
Bug: unable to reload users information when reassigning organizati...
Prerequisites I have searched the repository’s issues and Kinde community to ensure my issue isn’t a duplicate I have checked the latest version of the library to replicate my issue I have read the...
TotalScrub
TotalScrub2w ago
It will be slightly different in React and it's possible that they may have already implemented a switchOrg helper as mentioned by Daniel in the GitHub issue
__maxom__
__maxom__OP2w ago
Thanks heaps @Stephen , will look into this.

Did you find this page helpful?