question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot resolve endpoints when used in combinaison with mailgun-js

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Mrtblgcommented, 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 !

1reaction
jasonnuttercommented, Aug 22, 2022

More detail: https://github.com/MONEI/Shopify-api-node/issues/406#issuecomment-678069541

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

User Manual — Mailgun API documentation
Introduction¶. This document is meant to be an overview of all of the capabilities of Mailgun and how you can best leverage those...
Read more >
Mailgun REST API Documentation
Learn how to send email from your app, SMTP vs API, verifying your domain, email reputation; we'll explain it all here. Once you...
Read more >
Events — Mailgun API documentation
Mailgun tracks every event that happens to your emails and makes this data available to you through the Events API. Mailgun retains this...
Read more >
Which SMTP Port Should I Use? Understanding Ports 25, 465 ...
Which SMTP port should you use — port 25, port 465, or port 587? Click to learn more about Mailgun's guide to understanding...
Read more >
Easily integrate forms into your app with Mailgun and Form.io
We're excited to announce the integration of Mailgun with Form.io, an open‐source combined FORM and API creation and management platform ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found