diff --git a/src/hooks/useAADAuth.ts b/src/hooks/useAADAuth.ts index 630521f2d..5964707fd 100644 --- a/src/hooks/useAADAuth.ts +++ b/src/hooks/useAADAuth.ts @@ -56,6 +56,7 @@ export function useAADAuth(): ReturnType { }); setTenantId(response.tenantId); setAccount(response.account); + localStorage.setItem("cachedTenantId", response.tenantId); }, [account, tenantId] ); diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 686391376..24c100eb8 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -98,9 +98,11 @@ async function configureHostedWithAAD(config: AAD): Promise { const msalInstance = getMsalInstance(); const cachedAccount = msalInstance.getAllAccounts()?.[0]; msalInstance.setActiveAccount(cachedAccount); + const cachedTenantId = localStorage.getItem("cachedTenantId"); const aadTokenResponse = await msalInstance.acquireTokenSilent({ forceRefresh: true, scopes: [hrefEndpoint], + authority: `${configContext.AAD_ENDPOINT}${cachedTenantId}`, }); aadToken = aadTokenResponse.accessToken; }