User switch between Organization

Answering some questions that I posed after some digging around for an implentation.

Using the React-sdk, we can use the getAccessTokenSilently from the auth0 hook and pass in organization (similar to the same prop on the Auth0Provider) with the new org_id when a user wants to switch organization.

To do this, we have to pass in the ignoreCache flag when we get the access token (otherwise you’d get the same access token for the same organization.

Drawback is obvious, if a user switches back and forth between organizations, without some caching locally, we are making multiple calls to the API.

2 Likes