Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loginPopup() never returns when redirect page is on another domain #7370

Closed
willlahr opened this issue Oct 9, 2024 · 1 comment
Closed
Labels
documentation Related to documentation. msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@willlahr
Copy link

willlahr commented Oct 9, 2024

Core Library

MSAL.js (@azure/msal-browser)

Wrapper Library

Not Applicable

Public or Confidential Client?

Public

Documentation Location

docs.microsoft.com

Description

I've got a single page SPFx app which is aiming to get some api tokens to pass to another app in order to let it access the graph api. My SPFx app calls loginPopup() and everything goes well, to the point where my redirect page (on a different domain from the SPFx app) is rendered and has a code and client_info in the url. I've not found any authorititave docs on how this process is suppsed to be completed. CoPilot has suggested running msalInstance.handleRedirectPromise(window.location.href)
But with extra logging turned on i can see that i get the message: '[email protected] : Info - handleRedirectPromise called but there is no interaction in progress, returning null.'
I can see that the initial call to loginPopup() is waiting for something, and it correctly throws an error (user_cancelled) if i just close the popup, so it doesn't seem like I'm that far off where I should be. I can't find a page or example in the documents that describes the flow for loginPopup() and I'm not sure if this is even the right approach.

@willlahr willlahr added documentation Related to documentation. question Customer is asking for a clarification, use case or information. labels Oct 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Oct 9, 2024
@github-actions github-actions bot added msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications labels Oct 9, 2024
@tnorling
Copy link
Collaborator

This is expected behavior as per design. The redirectUri must be on the same domain as where you started the flow. The browser blocks access to the hash fragment and storage in cross-origin contexts for privacy reasons and this is a hard technical blocker even if we wanted to try to support this use case.

For SPFx apps you should be using Sharepoint's auth library instead of MSAL directly

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Attention 👋 Awaiting response from the MSAL.js team label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation. msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

2 participants