Skip to content
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

Cannot resolve endpoints when used in combinaison with mailgun-js #5114

Closed
Mrtblg opened this issue Aug 18, 2022 · 8 comments
Closed

Cannot resolve endpoints when used in combinaison with mailgun-js #5114

Mrtblg opened this issue Aug 18, 2022 · 8 comments
Assignees
Labels
answered Question has received "first qualified response" confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package question Customer is asking for a clarification, use case or information.

Comments

@Mrtblg
Copy link

Mrtblg commented Aug 18, 2022

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?

Confidential

Description

When importing "mailgun-js": "^0.22.0" (latest) the msal library will fail oAuth with an error message

The bug is very easy to reproduce, juste create a running application with the following package.json

"dependencies": {
    "@azure/msal-node": "^1.12.1",
    "express": "^4.17.2",
    "mailgun-js": "^0.22.0"
  }

Then in your running and working application just add const mailGun = require("mailgun-js"); try to oAuth and you will get an error.
Comment the line const mailGun = require("mailgun-js"); and oAuth works again.

Somehow importing mailgun-js messes up msal-node

Error Message

{"errorCode":"endpoints_resolution_error","errorMessage":"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://undefined/common/v2.0/.well-known/openid-configuration","subError":"","name":"ClientAuthError"}

Msal Logs

[Thu, 18 Aug 2022 17:35:48 GMT] : @azure/msal-node@1.12.1 : Info - getAuthCodeUrl called
[Thu, 18 Aug 2022 17:35:48 GMT] : @azure/msal-node@1.12.1 : Verbose - initializeRequestScopes called
[Thu, 18 Aug 2022 17:35:48 GMT] : [c990a71c-7df6-429b-a8a5-7822e83c3893] : @azure/msal-node@1.12.1 : Verbose - buildOauthClientConfiguration called
[Thu, 18 Aug 2022 17:35:48 GMT] : [c990a71c-7df6-429b-a8a5-7822e83c3893] : @azure/msal-node@1.12.1 : Verbose - building oauth client configuration with the authority: https://login.microsoftonline.com/common/
[Thu, 18 Aug 2022 17:35:48 GMT] : [c990a71c-7df6-429b-a8a5-7822e83c3893] : @azure/msal-node@1.12.1 : Verbose - createAuthority called
{"errorCode":"endpoints_resolution_error","errorMessage":"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://undefined/common/v2.0/.well-known/openid-configuration","subError":"","name":"ClientAuthError"}

MSAL Configuration

{
  auth: {
    clientId: "...",
    clientSecret: "...",
  },
  system: {
    loggerOptions: {
      loggerCallback(loglevel, message, containsPii) {
        console.log(message);
      },
      piiLoggingEnabled: false,
      logLevel: msal.LogLevel.Verbose,
    },
  },
}

Relevant Code Snippets

The exemple code of the ms-identity-node-main

Reproduction Steps

Intall "mailgun-js": "^0.22.0"
import/require it
try to oAuth

Expected Behavior

It should be working along with mailgun-js

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

None (Server)

Regression

No response

Source

External (Customer)

@Mrtblg Mrtblg added bug-unconfirmed A reported bug that needs to be investigated and confirmed question Customer is asking for a clarification, use case or information. labels Aug 18, 2022
@ghost ghost added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Aug 18, 2022
@github-actions github-actions bot added confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package labels Aug 18, 2022
@ghost ghost assigned jennyf19, jmprieur and bgavrilMS Aug 18, 2022
@Mrtblg
Copy link
Author

Mrtblg commented Aug 19, 2022

Hello @bgavrilMS @jmprieur @jennyf19 I absolutely need to get this working for the beginning of september to provide SSO to a big client using AzureAD.
Can you give me a level of prioritiazation on your end ?

Thank you for your update

@bgavrilMS
Copy link
Member

Hi @Mrtblg - this is just a network error, an http call cannot be made. Looking closely to the error, it looks like you might have not configured the authority. See "undefined" there.

image

@ghost ghost added answered Question has received "first qualified response" Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Aug 22, 2022
@bgavrilMS bgavrilMS added Needs: Attention 👋 Awaiting response from the MSAL.js team answered Question has received "first qualified response" and removed bug-unconfirmed A reported bug that needs to be investigated and confirmed answered Question has received "first qualified response" Needs: Author Feedback Awaiting response from issue author labels Aug 22, 2022
@Mrtblg
Copy link
Author

Mrtblg commented Aug 22, 2022

Hi @bgavrilMS I know it might look like it at first glance.

But in reality the problem is caused some how by the const mailGun = require("mailgun-js");.
As I said, as soon as I comment this line (without any other change in the configuration or authority), suddenly the http call is made correctly and everything is working as expected.
As soon as I uncomment back the line, the problem is back.

Somehow, there is something in your library that is impacted by the const mailGun = require("mailgun-js"); line and messes things up.

Have you tried to add the package "mailgun-js": "^0.22.0" to the exemple code of the ms-identity-node-main provided by microsoft and add the const mailGun = require("mailgun-js"); line ?
I definitely think it is a real bug.

@bgavrilMS
Copy link
Member

@derisen - do you have any idea what's happening?

@ghost ghost added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Aug 22, 2022
@bgavrilMS
Copy link
Member

bgavrilMS commented Aug 22, 2022

@Mrtblg - afaik, you can introduce your own network layer, see

networkClient: NetworkUtils.getNetworkClient(),
/ INetworkClient - maybe this can be used as a workaround.

CC @Robbie-Microsoft

@jasonnutter
Copy link
Contributor

Looks like this could be caused by something in mailgun-js: mailgun/mailgun-js-boland#265 (comment)

@jasonnutter
Copy link
Contributor

More detail: MONEI/Shopify-api-node#406 (comment)

It looks like nodemailer does not have this issue, so please try switching to it (also note that mailgun-js is deprecated and unlikely to be updated).

@Mrtblg
Copy link
Author

Mrtblg commented Aug 22, 2022

@jasonnutter thank you for the investigation. mailgun-js is deprecated indeed and does mess-up https requests.

I migrated to mailgun.js which is the new official library and it all seams to work as expected 👍

Thank you for your help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Question has received "first qualified response" confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

5 participants