cli-microsoft365: Bug report: M365 login from behind corp proxy = Error: could not resolve endpoints
Description
I’m attempting to setup and configure M365 CLI on some of our servers which are behind a proxy and I’m running into issues with the setup, probably something I’m missing but I’m not overly familiar with node/npm etc.
Steps to reproduce
Firstly I installed nodejs
Then ran
npm config set proxy http://proxyname:port npm config set https-proxy http://proxyname:port
and then npm install -g @pnp/cli-microsoft365
install took place and m365 status = logged out. So the module installed, just an issue connecting.
Expected results
M365 Login should prompt me to visit Azure to validate my login using the browser.
Actual results
Running m365 login returns:
Error: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: Clie tConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this author ty in the knownAuthorities config parameter.
Diagnostics
I’ve double checked the proxies and they return as the correct values from above
npm config get proxy http://proxyname:port
npm config get https-proxy https://proxyname:port
CLI for Microsoft 365 version
v3.13.0
nodejs version
v14.17.5
Operating system (environment)
Windows Server 2016 x64 1607
Shell
Windows PowerShell 5.1
cli doctor
Error: Log in to Microsoft 365 first
Additional Info
Some pointers on what I’m missing would be appreciated. TIA
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 53 (33 by maintainers)
Commits related to this issue
- Adds the ability to use a proxy. Closes #2698 — committed to Jwaegebaert/cli-microsoft365 by nicodecleyre a year ago
Hey, thanks for all the great work on this.
It would be cool if it the
http_proxyorhttps_proxyenvironment variables were used (if proxyUrl is not set). See https://github.com/pnp/cli-microsoft365/issues/2698#issuecomment-918233174Thank you for offering your help @user799595!
I’ve created a dev environment with a proxy like the article explained in the link that @anthonywhite shared and was able to reproduce the error message. I’ll take a deeper look to it in the coming days and investigate if the msal update that @waldekmastykarz shared can offer a solution to this.
I’ll keep you posted
@anthonywhite the instructions help for sure! I’m on a macOS so I’ll either try for an alternative or use a VM, unless someone else who’s on Windows would like to help with addressing this limitation 😄
Happy to help any way I can and I’m sure that our contributors feel the same way! If we can get to a representative setup, then we can definitely work on a solution. Let’s do this!
We may have found a breaktrough here!
With the msal version we currently use (1.15.0) there is the possibility to provide a proxy url. By providing an additional option
proxyUrlwith them365 loginit targets the login towards the proxy. Next to that this same option is also provided when doing the actual requests as you can see in the example where I execute them365 spo web listcommand.This is not yet in production! I’ll make a pull request and then we still have to review and test this new functionallity. But i’m really exited about this since it can provide an added value for people behind a corporate proxy
Ps: can a maintainer assign me to the issue please?
Thank you for your feedback everyone! I’ll get to work with the feedback
proxyUrlis a good name for the setting. It’s clear what it’s for.As it applies to using CLI at large, I suggest we follow @martinlingstuyl’s suggestion and add it to the guide. Additionally, we should include this in the
m365 setupcommand #4216Hi @nicodecleyre, great work researching this! I’d suggest we add a separate section to the using guides. Something like ‘Working behind a proxy’.
@nicodecleyre awesome research 👍. I assigned to you as you suggested
Awesome. @nicodecleyre thank you once again for your truly amazing engagement and dedication 👍. You rock 🤩
We’d need to check if the latest versions of MSAL and Axios still have this limitation. It’s been a while since we looked at this issue and we’ve had a couple of updates since
@waldekmastykarz Could something like this help (please note I have not tried myself - I already have a corporate proxy 😉)?
Simulate-an-enterprise-proxy-on-a-single-developer-machine
I appreciate this is a pain for your authors/contributors, but the uncomfortable fact is that a percentage of your users, especially in large companies or regulated industries, are sat behind corporate proxies trying to make dev toolchains work. And the experience is very mixed, some things work and some don’t. I’ve had a lot of pain in this area over many years.
If you do feel able to simulate this use case, that would be much appreciated.
👍 yes please nothing has changed for us.
It seems like just recently there was an update to msal-node that adds support for proxy. @pnp/cli-for-microsoft-365-maintainers we should check it out if it helps addressing this issue.
More info: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/2600#issuecomment-1048295218
@anthonywhite - would you mind sharing the results of the TLS version check on your proxy, as mentioned above? We’re collectively, and I don’t have an environment such as yours to test on, trying to figure out what’s going on with your environments. It’s obvious to me that something is going on with the proxy configuration that does not work with the M365 CLI setup, and we’re trying to pinpoint where things go wrong.
According to the error message my guess is that there’s an issue with the TLS version.
For instance login.microsoftonline.com requires TLS 1.2 or greater. Can be tested with
curl https://login.microsoftonline.com --verbose --tlsv1.1 --tls-max 1.1That fails, and the following succeeds:
curl https://login.microsoftonline.com --verbose --tlsv1.2 --tls-max 1.2@mikeparkie - Can you run the same things but on your proxy address?
@waldekmastykarz indeed I have sir. Rebooted it again just in case 😎
Typically I’m more of an M365 guy than Azure, so I’ll be blocked at some point from a role point of view. But let’s see how far I get 😄
Installed the Azure CLI from the MSI from here, ran
az login --debugFull output is:
Bear in mind that Azure CLI is built in Python and it could have a different support for handling proxies. So far, it seems like the issue is with msal-node and that’s the first place that we should investigate to see if there are any known issues before we continue.