OneDrive / samples

Contains samples, scenarios, and guidance for integrating with OneDrive and SharePoint drives, drive items, and files.
MIT License
58 stars 59 forks source link

Authentication Login popup blocked by browser #26

Closed chrisbekas closed 1 year ago

chrisbekas commented 1 year ago

Describe the bug I'm using the javascript-basic-consumer sample project. When first using the file picker, the first popup window is displayed, however the second authentication popup is blocked by the browser.

patrick-rodgers commented 1 year ago

Hi @chrisbekas - the sample works for default browser configurations, can you ensure you don't have any enhanced pop-up blocking present? This isn't as much an issue with the picker as with the MSAL library - we've used a generic auth pattern in the sample, it might be that you need to use a different approach for your environment.

chrisbekas commented 1 year ago

Thanks @patrick-rodgers No enhanced pop-up blocking, just standard browser configuration (checked with Chrome, Firefox and Edge) and running on localhost:3000.

Indeed the console message Uncaught (in promise) BrowserAuthError: popup_window_error: Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser. Details: BrowserAuthError: empty_window_error: window.open returned null or undefined window object. refers to the MSAL library but what is the recommended approach when most users will not notice or grant access to popups?

patrick-rodgers commented 1 year ago

You can use the redirect flow that will redirect the user. This article outlines the available options depending on the type of thing you are building. You might consider authenticating them prior to showing the pop-up for the picker so you are ready to provide tokens.

You haven't shared what type of thing you are building so hard to give any specific guidance.

chrisbekas commented 1 year ago

Great, thanks for the info @patrick-rodgers. We can authenticate users prior to showing the picker so I guess that overcomes the popup issue.