-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Acquire token in pop-up window managed by library caller #7362
Comments
You can use |
Thank you @tnorling for quick reply! Please, give me a day or two to check out your proposal. |
On one hand I managed to achieve end goal, on the other it requires some boilerplate to get the job done. I wonder if my initial proposal - to make the window customizable via parameter in popup flow - could still be considered as a feature proposal. In case someone runs into similar problem, I'm sharing example snippets of code illustrating how I dealt with the problem, following advice from @tnorling. Please keep in mind this is just example to show happy-path flow, without proper validation and error handling. Code in parent window
Content of landing-page.html
|
Thanks for following up to confirm that worked for you! As of right now we have no plans to add support for this outside of |
Core Library
MSAL.js (@azure/msal-browser)
Wrapper Library
Not Applicable
Public or Confidential Client?
Public
Description
Hello!
Summary
I would like to have an ability to control lifetime of pop-up window that is currently spawned by
PublicClientApplication.acquireTokenPopup(request: PopupRequest): Promise<AuthenticationResult>
. Currently the method opens pop-up window, performs authentication and closes pop-up on successful authentication, resolving the promise with authentication result. My idea is to add optional parameterpopupWindow?: Window
toPopupRequest
. If set, its value would be used as a host for authentication prompt instead of spawning new window.Example use case
Let's consider following example: user clicks on a button that would connect them to external service, i.e. OneDrive. Control allowing interaction with external service should be spawned in separate window. Before user can use the service, they must first authenticate via Microsoft Entra ID authentication. Since interaction with the service will be taking place in separate window, it seems intuitive to perform authorization also in the same window. Moreover, browser ad-blocker will prevent opening multiple windows (one for authentication purpose, the other one for service integration).
My first thought is that web application should control the lifetime and the content of single window, so it can serve both purposes.
Considered workarounds
Another idea that crossed my mind is to spawn new window and use
PublicClientApplication.acquireTokenRedirect(request: RedirectRequest): Promise<void>
in its context somehow. This has the downside of ... well, following redirect logic. After user is done with the authentication, this must be somehow communicated to the parent window.acquireTokenPopup
interface seems much easier for this purpose.Please, let me know what you think. Maybe there is some flow or wiring in existing implementation that I have missed that could lead to same or similar result as described in "Example use case" section?
Thanks in advance,
Artur
Source
External (Customer)
The text was updated successfully, but these errors were encountered: