Pretty much every Authorization Server login screen will refuse to render on an iframe by default, as a protection against clickjacking. So redirecting on an iframe will not work. There may be a way to allow this in Azure but I kind of doubt it.

Not sure if there is a solution in sight for you, and it is not a simple thing you are asking for. As a general rule you need to design for security early. A couple of possibilities:

PART 1

Make your hosting domains compatible along these lines, so that cookies or tokens (what ever you are using) can potentially be shared between the apps:

  • https://web.mycompany.com/app1
  • https://web.mycompany.com/app2

PART 2

Define an interface within the inner (iframe) app for dealing with logins. When the inner app detects that it is running in an iframe it needs to use an implementation that asks the main (host) app to perform things like login redirects on its behalf.

You may then need to issue a cookie across the 2 apps (with a site wide scope) or use the postMessage API to send tokens back to the iframe app (and there are potential security risks with this).

Answer from Gary Archer on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 942794 › login-microsoftonline-com-refused-to-connect
login.microsoftonline.com refused to connect - Microsoft Q&A
2 comments Hide comments for this question Report a concern · I have the same question I have the same question 0 {count} votes · Alfredo Revilla - Upwork Top Talent | IAM SWE SWA • ... Hello @Justin Miller , it's correct, "X-Frame-Options" set to "deny" is there to prevent clickjacking. Such security measure cannot be relaxed however you might try solutions involving pop-ups and web sockets like the ones described in Connecting to Office 365 from an Office Add-in - Why Pop-ups are a Necessary Evil.
🌐
Dynamics Community
community.dynamics.com › forums › thread › details
My iFrame displays login.microsoftonline.com refused to connect
Our D365 app presents an iframe on a form which loads another website (different domain) which conducts some Q and A then returns to a 'completed' page which is a D365 webresource html page · This works most of the time but occasionally we see 'login.microsoftonline.com refused to connect' ...
🌐
Microsoft Community Hub
techcommunity.microsoft.com › microsoft community hub › communities › products › content management › sharepoint
Create Site error, login.microsoftonline.com refused to connect. | Microsoft Community Hub
But everytime I click 'Create Site' I keep getting this error message: 'login.microsoftonline.com refused to connect'. At the same time I'm logged into several other MS apps with zero connectivity problems.
🌐
Stack Exchange
sharepoint.stackexchange.com › questions › 309340 › login-microsoftonline-com-refused-to-connect-with-spfx
sharepoint online - login.microsoftonline.com refused to connect with SPFx - SharePoint Stack Exchange
One suggestion is to set isDomainIsolated = false in your package-solution.json file. This may solve the issue of login.microsoftonline.com refusing to connect.
🌐
SAP
userapps.support.sap.com › sap › support › knowledge › en › 3521138
3521138 - Unable to access CPQ quote via C4C mashup. Error: "login.microsoftonline.com refused to connect"
This issue is not related to CPQ but to the Microsoft IdP configuration for iFrame settings, which is blocking the connection. Configuration for iFrame on the Microsoft IdP in use should be reviewed. As starting point please refer: https://learn.microsoft.com/en-us/answers/questions/957121/login-microsoftonline-com-refused-to-connect-on-xf ".
Find elsewhere
🌐
Developer Community
developercommunity.visualstudio.com › t › loginmicrosoftonlinecom-refused-to-connect-with-ms › 1504803
login.microsoftonline.com refused to connect with msit. ...
Skip to main content · Microsoft · Visual Studio · Sign in · You need to enable JavaScript to run this app · Sorry this browser is no longer supported · Please use any other modern browser like 'Microsoft Edge'
🌐
GitHub
github.com › SharePoint › sp-dev-docs › issues › 7135
login.microsoftonline.com refused to connect in spfx solution · Issue #7135 · SharePoint/sp-dev-docs
March 11, 2021 - Initially i thought in permission error, but the users with the problem can access to the webpart with his office 365 account from the computer of a user without problems.
Published   Jul 01, 2021
🌐
GitHub
github.com › microsoftarchive › Learn-LTI › issues › 206
login.microsoftonline refused to connect · Issue #206 · microsoftarchive/Learn-LTI
March 14, 2022 - Bug For some users (about 10 %) they have an error "login.microsoftonline refused to connect" when attempting to access the MS Learn content. This is what we expect to see LMS (please com...
Published   Aug 30, 2022
🌐
Seminarsonly.com
seminarsonly.com › home › error fix › fixed : login.microsoftonline.com refused to connect
Fixed : login.microsoftonline.com Refused to Connect
June 23, 2025 - If you're seeing the error "login.microsoftonline.com refused to connect", it usually means there's an issue with how a Microsoft login page is being loaded—either in your browser, an embedded frame, or a third-party app.
🌐
Liveassistfor365
support.liveassistfor365.com › hc › en-us › articles › 12596114847639-How-to-fix-the-agent-widget-error-login-microsoftonline-com-refused-to-connect
How to fix the agent widget error "login.microsoftonline.com refused to connect" – Live Assist for 365 Support
After installing Live Assist for Dynamics 365 (LAD365), some users might not be able to load the agent widget. They may encounter an error that states "login.microsoftonline.com refused to connect....
🌐
GitHub
github.com › pnp › pnpcore › discussions › 763
'login.microsoftonline.com refused to connect' error when running in an iframe · pnp/pnpcore · Discussion #763
I expect the issue is similar to what is described here: https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/425761/my-iframe-displays-login-microsoftonline-com-refused-to-connect---but-only-sometimes Maybe the response is also relevant in this case: 'It seems that the OAuth 2.0 acces tokens expire and are renewed in the background but this won't apply to the iframe so attempts to redirect fail as we are no longer logged in.
Author   pnp
🌐
Reddit
reddit.com › r/office365 › login not working anymore (404 - login.microsoftonline.com)
r/Office365 on Reddit: Login not working anymore (404 - login.microsoftonline.com)
November 15, 2023 -

Hi,
I have a strange problem with one user.
Since yesterday evening, his outlook was "offline". It only tries to connect to O365, but the connection could not be established.
So I tried online-mode, which doesnt worked either. I also tried a new profile, but i don't get to the mask to put the password in. The modern Auth window opens, but is giving me the error
404 - login.microsoftonline.com
It works with OWA, SaRa also prompted for a password.

What can I do, to get it running again?