loadExternalTokens no longer works with aquireTokenSilent #7527
Labels
bug-unconfirmed
A reported bug that needs to be investigated and confirmed
msal-browser
Related to msal-browser package
msal-react
Related to @azure/msal-react
Needs: Attention 👋
Awaiting response from the MSAL.js team
public-client
Issues regarding PublicClientApplications
question
Customer is asking for a clarification, use case or information.
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
4.0.1
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
3.0.1
Public or Confidential Client?
Public
Description
Hello,
When using the
loadExternalTokens
the assumption is that the aquireTokenSilent request will not prompt with a redirect. However this seems to not be the case and a redirect login is always showing up.At one point this work 100% correctly, but now it seems no matter what I try that will no longer set the account, even tho all the tokens are their in the sessionStorage.
I have created a repo to go over this more in depth and have it be a sandbox for other to try or tell me what is wrong in the code. The readme should be more indepth and have all the repro steps.
Here is the repo
The use case is we have a selenium runner that does a fetch for the tokens are our MS endpoint
https://login.microsoftonline.com/tenatId-here/oauth2/v2.0/token
that then gets transformed into session storage values for ouruseAuthetication
hook to receive values such as 'seleniumIdTokenKey' these values are then read and fed into call to our pca like soawait pca.getTokenCache().loadExternalTokens(silentRequest, serverResponse, loadTokenOptions);
At which point a user should be logged in once they reach a page that has a<MsalAuthenticationTemplate interactionType={InteractionType.Redirect}>
wrapped around the rendered child component.The sample code comes from this document here
Note: This token from
https://login.microsoftonline.com/tenatId-here/oauth2/v2.0/token
comes back correctly and when using the "access_token" property off it, it is able to hit out api's and auth correctly. We know it's not the token and have also tried it with multiple app registrations as well as a brand new one.In the sample repo this redirect always prompts a login prompt and doesn't appear to read from our sessionStorage items anymore.
This seemed to work until about mid Oct of 2024 on msal 2.2.
This also seems to work without loadExternalTokens on msal 1, but we don't wanna downgrade.
Other issues that seem related are as follows:
One in SO
one in github
Error Message
The only error message sometimes provided was a
https://autologon.microsoftazuread-sso.com/our-tenantId-here/winauth/ssoprobe?client-request-id=01946bbe-a6ee-729b-af2e-31545463d6d7&_=1736974445488 - Failed to load resource: the server responded with a status of 401 (Unauthorized)
MSAL Logs
No response
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Clone the repo, follow the Prerequisites steps.
Grab a result from https://login.microsoftonline.com/your-tenant-id-here/oauth2/v2.0/token, and paste that into the textarea of the application. Once pasted hit "set sessionStorage & slient redirect" button on the application homepage.
Expected Behavior
The login prompt should not appear as loadExternalTokens should be satisfied. Once a result from the MS endpoint is pasted into the textarea anbd the "set sessionStorage & slient redirect" is press, the app would redirect to an authed page. just like if a user signed in regularly
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome, Firefox, Edge
Regression
@azure/msal-browser: 3
The text was updated successfully, but these errors were encountered: