You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1916,6 +1918,62 @@ If you want to support multiple domains, you would have to pass an array of obje
1916
1918
1917
1919
You can skip sending the `customScheme` property if you do not want to customize it.
1918
1920
1921
+
#### Switching tenants at runtime
1922
+
1923
+
The configuration above is **build-time** setup: it registers the redirect callback for every domain you intend to use. Switching the _active_ tenant while the app is running is done in JavaScript by changing the `domain`/`clientId` you pass to the SDK.
1924
+
1925
+
When you change the `domain` or `clientId` prop on `Auth0Provider`, the provider rebuilds its underlying client so subsequent calls target the newly selected tenant. Keep the props in state and update them to switch:
onPress={() =>setIndex((i) => (i +1) %TENANTS.length)}
1946
+
/>
1947
+
<LoginScreen />
1948
+
</Auth0Provider>
1949
+
);
1950
+
};
1951
+
```
1952
+
1953
+
After switching, the next `authorize()` call opens the login page for the newly selected tenant and the redirect resolves correctly, provided that tenant's domain/scheme was registered using the build-time configuration shown above.
1954
+
1955
+
> Note: Switching tenants does not immediately clear the displayed auth state. The provider re-runs its initialization for the new tenant and updates `user` once that check completes, so the previously shown user may briefly remain until then. Persisted credentials are stored per tenant, so a user already logged in to the target tenant is restored on initialization; otherwise `user` becomes `null`.
1956
+
1957
+
If you are using the `Auth0` class directly instead of the hooks, simply create (or reuse) an instance per tenant and call the one matching the active tenant:
1958
+
1959
+
```js
1960
+
importAuth0from'react-native-auth0';
1961
+
1962
+
constclients= {
1963
+
tenantA:newAuth0({
1964
+
domain:'tenant-a.us.auth0.com',
1965
+
clientId:'CLIENT_ID_A',
1966
+
}),
1967
+
tenantB:newAuth0({
1968
+
domain:'tenant-b.us.auth0.com',
1969
+
clientId:'CLIENT_ID_B',
1970
+
}),
1971
+
};
1972
+
1973
+
// Use whichever client corresponds to the active tenant.
On Android, some browsers do not correctly handle App Link redirects. For example, Firefox renders the callback URL as a web page instead of handing the redirect back to your app, causing the authentication flow to fail silently.
0 commit comments