Class VisualStudioCodeCredential
Enables authentication to Microsoft Entra ID as the user signed in to Visual Studio Code via the 'Azure Account' extension.
It's a known issue that VisualStudioCodeCredential
doesn't work with Azure Account extension
versions newer than 0.9.11. A long-term fix to this problem is in progress. In the meantime, consider authenticating
with AzureCliCredential.
public class VisualStudioCodeCredential : TokenCredential
- Inheritance
-
VisualStudioCodeCredential
Constructors
VisualStudioCodeCredential()
Creates a new instance of the VisualStudioCodeCredential.
public VisualStudioCodeCredential()
VisualStudioCodeCredential(VisualStudioCodeCredentialOptions)
Creates a new instance of the VisualStudioCodeCredential with the specified options.
public VisualStudioCodeCredential(VisualStudioCodeCredentialOptions options)
Parameters
options
VisualStudioCodeCredentialOptionsOptions for configuring the credential.
Methods
GetToken(TokenRequestContext, CancellationToken)
Gets an Azure.Core.AccessToken for the specified set of scopes.
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
Parameters
requestContext
TokenRequestContextThe Azure.Core.TokenRequestContext with authentication information.
cancellationToken
CancellationTokenThe CancellationToken to use.
Returns
- AccessToken
A valid Azure.Core.AccessToken.
Remarks
Caching and management of the lifespan for the Azure.Core.AccessToken is considered the responsibility of the caller: each call should request a fresh token being requested.
GetTokenAsync(TokenRequestContext, CancellationToken)
Gets an Azure.Core.AccessToken for the specified set of scopes.
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
Parameters
requestContext
TokenRequestContextThe Azure.Core.TokenRequestContext with authentication information.
cancellationToken
CancellationTokenThe CancellationToken to use.
Returns
- ValueTask<AccessToken>
A valid Azure.Core.AccessToken.
Remarks
Caching and management of the lifespan for the Azure.Core.AccessToken is considered the responsibility of the caller: each call should request a fresh token being requested.