-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
msal-node: Electron (v20) / create-react-app (5) : ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. #5138
Comments
@RadIsACoder What version does your package-lock say is installed when it does work? Have you looked at your network requests to see if you can determine why the call to the well-known endpoint is failing? |
Hi Thomas, Nothing I'm afraid. Screenshot attached. Exact steps to reproduce: Node v18.3.0
yarn start .. No problems on localhost:3000
create
index.js
Results in ... ERROR in ./node_modules/@azure/msal-node/dist/msal-node.esm.js 3:0-24 BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. If you want to include a polyfill, you need to: Then follow exact process outlined here: (https://www.alchemy.com/blog/how-to-polyfill-node-core-modules-in-webpack-5) ... No AuthCodeUrl ... PublicClientApplication instance is created though. Also note its working with React Scripts 4 Thanks again |
I was also hopeful when I used MSAL React, which made things much easier ( and worked) but it wouldn’t run when integrating with Electron. This is unexpected as the components in Electron are simply being rendered using JS / JSX. The Node engine is completely isolated from the renderer and running in a different process. |
@RadIsACoder Did you try following the instructions in the error message to provide polyfills? We recently switched to using http instead of axios to make network requests - if that is unavailable in your environment network requests will not work. You may also find our Electron/React sample interesting. |
I followed the tutorial (above) to add polyfills. Webpack in CRA5 but is hidden so have to add fallbacks as per above to override the config settings. Thanks for the sample. Will check it out. |
@RadIsACoder To clarify, adding the polyfills did or did not solve the problem? |
Not yet but I'm going through the ElectronReactTestApp. Jut to clarify, whats the exact defintiion of "authority" in theMSAL config. The example gives
but another example on MSAL website gives:
Pretty confusing. Which one is it ? |
or is it this one ?
|
I am using B2C for my Electron React App but the test Electron React example is for AAD |
@Sectaur Authority is the url of the identity provider you are trying to acquire tokens from. All are valid, which you use depends on where your app registration and users reside. Since you're using B2C you should use the last example and fill in the placeholders with your specific tenant and policies |
Ok thanks. Will try it out. Re: Redirect URI - The previous app used "https://${TENANT_NAME}.b2clogin.com/oauth2/nativeclient" and "Allow Public ClientFlows" to "yes". To access the B2C user Flow, should I use this or "msal4b0db8c2-9f26-4417-8bde-3f0e3656f8e0://auth" ? I'm not sure why the "https:// " Redirect URI worked in production mode when the Electron-React App was deployed. Are there any examples of a Electron-React App accessing tokens with B2C / UserFlows ? Thanks for your patience. |
The redirectUri is the location where your app will listen for the response. It can be anything you like as long as it's something your app owns and understands how to read responses from. The sample I linked before sets up a custom protocol listener here with the following hostname which it then uses as the redircectUri. |
It doesn't work with the current set up. The PublicClientApplication instantiates normally but the code fails at client.getAuthCodeUrl(). The ElectronReactTest App also failed until we added this arcane "checks" Key which we found after lots of searching. "clientId": "123455-03aa-4f80-5rde-782b17c11859", The steps to reproduce are provided above. Here's a copy of the current package.JSON.
Thanks for your help, hopefully we can find the source of the error. |
Fails how?
What is this? This isn't a config option that MSAL.js recognizes. |
@RadIsACoder This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale. |
Core Library
MSAL Node (@azure/msal-node)
Core Library Version
1.12.1
Wrapper Library
Not Applicable
Wrapper Library Version
None
Public or Confidential Client?
Public
Description
I'm getting the following error:
ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientAuthError: openid_config_error: Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints. Attempted to retrieve endpoints from: https://sectaurapac.b2clogin.com/sectaurapac.onmicrosoft.com/b2c_1_sectaursignupsignin/v2.0/.well-known/openid-configuration
when setting up and invoking the PublicClientApplication.getAuthCodeUrl() method.
MSAL is being used to authenticate in a Desktop Electron App (with React).
The code with the same endpoints works with an older version, so ClientID and auth params are fine.
I have also "Allowed Public Client Flows" in Azure Portal.
I have also verified the end point by entering in browser which returns the relevant object:
but I am unable to debug this any further. How can I find the specific cause for this error ?
I am presuming this is a bug as it works on older set up:
Works (taken from package.JSON):
...
"@azure/msal-node": "^1.3.1",
"react": "^16.14.0",
"react-scripts": "4.0.3"
...
Current set up (CRA5 required polyfill override based on this article - https://www.alchemy.com/blog/how-to-polyfill-node-core-modules-in-webpack-5)
Package.JSON
Any help would be much appreciated.
MSAL Configuration
Relevant Code Snippets
Identity Provider
Azure B2C Basic Policy
Source
External (Customer)
The text was updated successfully, but these errors were encountered: