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.

@azure/identity error output doesn't show you the real error but gives you some nebulous message.

See original GitHub issue
  • Package Name: @azure/identity
  • Package Version: 2.0.4
  • Operating system: Debian
  • nodejs
    • version: v17.8.0
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug Running credential.getToken("https://database.windows.net/.default"); using the CLI path gets unhelpful error messages while the real error isn’t reflected. This is what I get:

/root/app/node_modules/@azure/identity/dist/index.js:1572
            const error = new Error(err.message || "Unknown error while trying to retrieve the access token");
                          ^

Error: Please run 'az login' from a command prompt to authenticate before using this credential.
    at AzureCliCredential.getToken (/root/app/node_modules/@azure/identity/dist/index.js:1572:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async DefaultAzureCredential.getToken (/root/app/node_modules/@azure/identity/dist/index.js:1401:25)
    at async /root/app/app.js:18:25

When I went into /node_modules/@azure/identity/dist/index.js to manually output to console the entire output object from const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId); (line 1542), I get this:

{
  stdout: '',
  stderr: "ERROR: AADSTS50005: User tried to log in to a device from a platform (Unknown) that's currently not supported through Conditional Access policy. Supported device platforms are: iOS, Android, Mac, and Windows flavors.\r\n" +
    'Trace ID: bb1647d8-1ddc-4f2c-a41b-7c5527f21000\r\n' +
    'Correlation ID: 83b46477-c9bf-4548-aade-309f072fc59f\r\n' +
    'Timestamp: 2022-03-31 11:12:50Z\n' +
    'To re-authenticate, please run:\n' +
    'az login --scope https://database.windows.net//.default\n',
  error: Error: Command failed: az account get-access-token --output json --resource https://database.windows.net/
  ERROR: AADSTS50005: User tried to log in to a device from a platform (Unknown) that's currently not supported through Conditional Access policy. Supported device platforms are: iOS, Android, Mac, and Windows flavors.
  Trace ID: bb1647d8-1ddc-4f2c-a41b-7c5527f21000
  Correlation ID: 83b46477-c9bf-4548-aade-309f072fc59f
  Timestamp: 2022-03-31 11:12:50Z
  To re-authenticate, please run:
  az login --scope https://database.windows.net//.default
  
      at ChildProcess.exithandler (node:child_process:398:12)
      at ChildProcess.emit (node:events:527:28)
      at maybeClose (node:internal/child_process:1090:16)
      at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
    code: 1,
    killed: false,
    signal: null,
    cmd: 'az account get-access-token --output json --resource https://database.windows.net/'
  }
}
/root/app/node_modules/@azure/identity/dist/index.js:1573
            const error = new Error(err.message || "Unknown error while trying to retrieve the access token");
                          ^

Error: Please run 'az login' from a command prompt to authenticate before using this credential.
    at AzureCliCredential.getToken (/root/app/node_modules/@azure/identity/dist/index.js:1573:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async DefaultAzureCredential.getToken (/root/app/node_modules/@azure/identity/dist/index.js:1401:25)
    at async /root/app/app.js:18:25

Expected behavior The actual error should be included in the error output.

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cephalincommented, Apr 14, 2022

@sadasant apart from manually inserting logging code into node_modules/@azure/identity/dist/index.js as I mentioned above, all I did was just following the error messages to enroll my device into InTune, etc. Which makes being able to see the error messages all the more important. There were other errors after the AADSTS50005 one, but it was pretty straightforward to fix one after another as long as I could see the error message.

0reactions
sadasantcommented, Apr 20, 2022

We have also made an issue to investigate supporting more error messages in the best way we can: https://github.com/Azure/azure-sdk-for-js/issues/21532

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure AD authentication & authorization error codes
Learn about the AADSTS error codes that are returned from the Azure AD security token service (STS).
Read more >
Issues · Azure/azure-sdk-for-js · GitHub
@azure/identity error output doesn't show you the real error but gives you some nebulous message. Azure.Identity Client This issue points to a problem...
Read more >
Jupyter Documentation - Read the Docs
When running the examples on the Try Jupyter site, you will get a ... Incorrect names will simply be ignored, with no error...
Read more >
What's in a good error message? - Hacker News
When I was in the Python interpreter and entered “exit”, which doesn't work ... A really evil programming language would give you an...
Read more >
The Schwartz Report - Redmondmag.com
Redmond magazine is The Independent Voice of the Microsoft IT Community. It is relied upon by Windows Server, SQL Server, Security, and Exchange...
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