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.

failed to retrieve token, but accesses KeyVault anyways

See original GitHub issue

Using the very first code example on the page and logging the credential to the console

const { DefaultAzureCredential } = require("@azure/identity");
const { SecretClient } = require("@azure/keyvault-secrets");

const credential = new DefaultAzureCredential();
console.log(credential)

results in

DefaultAzureCredential {
  UnavailableMessage: 'DefaultAzureCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit https://aka.ms/azsdk/js/identity/defaultazurecredential/troubleshoot.',
...

.

However, the following requests using the KeyVault client with

const client = new SecretClient(url, credential);

are successful. How can the client access the KeyVault without retrieving the token? Shouldn’t the token error above break the flow? 🤔

Cheers


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
xirzeccommented, Dec 1, 2022

@letzfets Since you are logging the credential object itself console.log(credential) you are seeing the property on the credential class that contains the message: https://github.com/Azure/azure-sdk-for-js/blob/857929dc41ed0dcf369092fb34f48f3b97525e9c/sdk/identity/identity/src/credentials/defaultAzureCredential.ts#L150

If you’d like to enable logging to see which credential succeeded, please consult https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#logging

1reaction
letzfetscommented, Dec 5, 2022

Yeah, makes sense now. Thank you so much. 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to retrieve OAuth access token using Azure Key vault ...
I am trying to use Azure Key vault scope in my Oauth 2.0 request to retrieve the access token using Client credentials grant...
Read more >
Failure to get token from Azure Key Vault - Stack Overflow
Multiple attempts failed to obtain a token from the managed identity endpoint. ... error: TS003: Error, TS004: Unable to get access token.
Read more >
AZIdentity | Key Vault Client: Why am I seeing HTTP 401?
Client makes an REST call to the Key Vault to retrieve the secret, but without an access token. This results in HTTP 401....
Read more >
Power Platform environment variable secrets from Azure Key ...
fetch the contained information from that environment variable: Azure subscription id, Resource Group name, Key Vault name and secret name; use ...
Read more >
Accessing Azure Key Vault from within Azure API Management
Key Vault Access Policies Let's go to the Access Policies pane of ... get-cached-secret Typically, we don't want to return a secret but...
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