Oren Pinkas
04/06/2026, 11:30 AMHi team, I need help implementing a custom "Admin/Dev Impersonation" flow.
The Goal:
We are a B2B SaaS with multiple Tenants + SSO. I want internal "Opmed" developers to be able to log in and access any client Tenant, while client users are still seamlessly routed to their specific IdP via Home Realm Discovery (HRD).
The Problem:
I tried associating an Opmed user (Google Social) with a demo Tenant via 'Authorization' on the user details page, but the Tenant Selector component is empty for that user. It works fine for the actual client user (SSO).
It seems like the "Shared SSO domain" template only scopes the Tenant Selector to active SSO connections, ignoring manual user-tenant associations.
Does anyone have tips on how to allow an internal user to "see" and select from multiple client tenants during login?
Meir Wahnon
04/06/2026, 11:46 AMAkash Jivane
04/06/2026, 11:57 AMssoDomainsTenantsCount to decide whether to show the tenant selector. This count is based on SSO domain matching β not direct user-tenant associations. Since your internal "Opmed" users log in via Google Social (not SSO), their email domain doesn't match any SSO domain configured on client tenants β the count comes back 0 or 1 β the Switch Tenant screen never renders (or renders empty).
The good news: the Switch Tenant component itself does work off user-tenant associations β the problem is the flow logic gating it.
Option 1 β Branch your flow for internal users (I would recommended this one) After collecting the email, add a condition that checks if the domain matches your internal domain (e.g. @opmed.com). If yes β authenticate via Google Social β show the Switch Tenant component directly (bypassing ssoDomainsTenantsCount entirely). If no β continue with the normal HRD/SSO path for client users.
For the Switch Tenant component to populate correctly, make sure your internal users are added to each client tenant via the Management API (the Authorization tab on the user profile page doesn't always behave the same way):
POST /v1/mgmt/user/update/tenant/add
{ "loginId": "<mailto:dev@opmed.com|dev@opmed.com>", "tenantId": "<client-tenant-id>" }
Or with the SDK: descopeClient.management.user.addTenant(loginId, tenantId)
Option 2 β Pre-set tenant via flow parameter Build a lightweight internal portal where devs pick a client tenant, then launch the Descope flow with the tenant parameter pre-set. This skips HRD completely and is clean for a dedicated impersonation/support tool. Docs: https://docs.descope.com/auth-methods/sso/with-flows#tenant-flow-parameter
Option 3 β Select Active Tenant post-auth Let the dev authenticate via Google Social (no tenant context), then call POST /v1/auth/tenant/select from your backend to switch their active tenant to any client tenant on demand. Most flexible for a fully programmatic impersonation flow.
Let me know if these options helps you to resolve the issue.Oren Pinkas
04/06/2026, 12:46 PMAkash Jivane
04/06/2026, 12:52 PMOren Pinkas
04/07/2026, 8:21 AMAkash Jivane
04/07/2026, 8:58 AM@opmed.com domain
2. Authenticate via Google Social (OAuth step completes here)
3. Then show the screen with the Switch Tenant component
Once step 2 completes, Descope has a resolved user session and the component will correctly read all associated tenants from their profile β including those added via the Management API.
A quick way to verify the association is working before fixing the flow: after calling addTenant, load the user via the API and confirm the userTenants array includes the expected tenant IDs:
GET /v1/mgmt/user?loginId=dev@opmed.com
If the tenants appear in that response, the association is correct and the flow ordering is the culprit.
Let me know what you find!Oren Pinkas
04/07/2026, 9:26 AMAkash Jivane
04/07/2026, 9:35 AM