Hi Descopers. I'm having an issue with adding cust...
# ask-a-descoper
a
Hi Descopers. I'm having an issue with adding custom tenant attributes to the JWT. We have a
pseudonym
attribute and the configuration pictured below. It works well when the user is only in a single tenant, but if they're in multiple tenants, the JWT contains
"pseudonym": "{{tenant.customAttributes.pseudonym}}"
instead of some representation of the list of pseudonyms, which is what I would expect. CC @Becca Barry
c
Hey Adam, You'll need to set the active tenant for it to know which tenant's custom attribute to display in the JWT. https://docs.descope.com/flows/screens/inputs/tenantselect-component You can also set the active tenant by passing the tenant ID in the Descope flow instantiation, or via a scriptlet override if you know which tenant you want selected during the flow execution.
a
Thanks, Chris. We already have our own switch tenant UI component. Is it possible to choose the tenant programmatically from the client SDK?
k
Hi @Adam Darlow, You can pass the tenant parameter in the SDK if that's what you mean. Here are the docs: https://docs.descope.com/flows/dynamic-keys/flow-inputs#using-flow-inputs
a
Not exactly. I was thinking of something like making an API call with the new DCT and getting back a new JWT
k
Oh I see, so basically exchanging one token for another from within the app, using your own component or something like that?
a
Yes, that's the idea
k
Gotcha, in that case there is an API you can use, that you can pass the refresh token into and set the tenant to something else (assuming said tenant is already associated with the user): https://docs.descope.com/api/session/active-tenant There are frontend SDK functions to handle this as well: https://github.com/descope/descope-js/blob/main/packages/sdks/core-js-sdk/src/sdk/index.ts#L92
a
That's just what I was looking for. Thanks!
✅ 1