network_error - Azure AD MSAL Node.JS

Mr. Genesis 1 Reputation point
2022-09-02T15:51:32.757+00:00

Hello!
I am trying auth using Node.JS, but when the app send the validation data throw an error and I not found what I am doing wrog.

237412-image.png

Text of message:
errorMessage: 'Network request failed. Please check network trace to determine root cause. | Fetch client threw: Error: Error: read ECONNRESET | Attempted to reach: https://login.microsoftonline.com/2bd70d8a-6f4e-4cc1-aa00-469ce9c54770/oauth2/v2.0/token'

Community Center Not monitored
{count} votes

3 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,486 Reputation points Volunteer Moderator
    2022-09-03T14:10:36.823+00:00

    Hi,

    The error says that you can't reach that url.

    Do you have basic internet connectivity from that machine?
    Do you have any firewall rules that prevents you from reaching login.microsoftonline.com?

    Hope this helps!

    0 comments No comments

  2. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    2022-10-03T21:35:10.17+00:00

    Hello @Mr. Genesis and thanks for reaching out. You code looks good. ECONNRESET means the other side of the TCP conversation abruptly closed its end of the connection. Since you're able to reach the /authorize endpoint and as @Cristian SPIRIDON suggests, you may have a (web) firewall or proxy blocking POST requests.

    Try running the code from a device in a network without proxy or firewall, it should work. Please reach your networking team to ensure POST requests to the /token endpoint are not being blocked or come back to us for additional debugging instructions.

    Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.


  3. Rishitha 0 Reputation points
    2024-06-06T16:05:20.1566667+00:00

    Hi. I have similar issue. Can someone help with this?

    Error getting token: AuthenticationRequiredError: network_error: Network request failed

    at handleMsalError (C:\node_modules\@azure\identity\dist\index.js:1564:12)
    
    at withSilentAuthentication (C:\node_modules\@azure\identity\dist\index.js:2046:23)
    
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    
    at async Object.withSpan (C:\node_modules\@azure\core-tracing\dist\commonjs\tracingClient.js:36:28) 
    
    at async CustomAuthenticationProvider.authProvider [as provider] (file:///C:/EmailDynamic.js:95:29) {
    

    scopes: [ 'https://graph.microsoft.com/.default' ],

    getTokenOptions: {

    tracingOptions: { tracingContext: [TracingContextImpl] },
    
    tenantId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    

    }

    }

    Error sending mail: AuthenticationRequiredError: network_error: Network request failed

    at handleMsalError 
    

    statusCode: -1,

    code: 'AuthenticationRequiredError',

    requestId: null,

    date: 2024-06-06T15:51:16.123Z,

    body: 'AuthenticationRequiredError: network_error: Network request failed',

    headers: undefined

    }

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.