azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[QUERY] How to replace GetAccessTokenAsync from Microsoft.Azure.Services.AppAuthentication

Open azerios opened this issue 3 years ago • 1 comments
trafficstars

Library name and version

Azure.Identity 1.6.1

Query/Question

Dear,

I was using Microsoft.Azure.Services.AppAuthentication and the GetAccessTokenAsync to get the access token of the scope "https://database.windows.net/"

Now with Azure.Identity I tried like this : var _defaultAzureCredential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { InteractiveBrowserTenantId = "TestTenant" //_tenantId });

var accessToken = await _defaultAzureCredential.GetTokenAsync( new TokenRequestContext(new[] { _azureServiceTokenProviderResource })).ConfigureAwait(false);

The issue is that the tenantId is ignored, it will use the one of my azure account and not the tenantId of my sql database. So the accessToken is always valid and I don't want this to be the case.

Is it possible to help me to fix this issue ?

Regards

Environment

No response

azerios avatar Aug 08 '22 20:08 azerios

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Aug 09 '22 12:08 jsquire

Hi @azerios - Are you sure that the credential being selected is the InteractiveBrowserCredential? Enabling logging may provide more helpful information - Details: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md#logging

christothes avatar Oct 31 '22 16:10 christothes

Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Nov 08 '22 08:11 ghost