KindeK
Kinde11mo ago
25 replies
__maxom__

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
Was this page helpful?