Table of Contents

Class SharedTokenCacheCredential

Namespace
Azure.Identity
Assembly
Azure.Identity.dll

Authenticates using tokens in a local cache file. This is a legacy mechanism for authenticating clients using credentials provided to Visual Studio. This mechanism for Visual Studio authentication has been replaced by the VisualStudioCredential.

public class SharedTokenCacheCredential : TokenCredential
Inheritance
SharedTokenCacheCredential

Constructors

SharedTokenCacheCredential()

Creates a new SharedTokenCacheCredential which will authenticate users signed in through developer tools supporting Azure single sign on.

public SharedTokenCacheCredential()

SharedTokenCacheCredential(SharedTokenCacheCredentialOptions)

Creates a new SharedTokenCacheCredential which will authenticate users signed in through developer tools supporting Azure single sign on.

public SharedTokenCacheCredential(SharedTokenCacheCredentialOptions options)

Parameters

options SharedTokenCacheCredentialOptions

The client options for the newly created SharedTokenCacheCredential

Methods

GetToken(TokenRequestContext, CancellationToken)

Obtains an Azure.Core.AccessToken token for a user account silently if the user has already authenticated to another Microsoft application participating in SSO through a shared MSAL cache. Acquired tokens are cached by the credential instance. Token lifetime and refreshing is handled automatically. Where possible, reuse credential instances to optimize cache effectiveness.

public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)

Parameters

requestContext TokenRequestContext

The details of the authentication request.

cancellationToken CancellationToken

A CancellationToken controlling the request lifetime

Returns

AccessToken

An Azure.Core.AccessToken which can be used to authenticate service client calls

GetTokenAsync(TokenRequestContext, CancellationToken)

Obtains an Azure.Core.AccessToken token for a user account silently if the user has already authenticated to another Microsoft application participating in SSO through a shared MSAL cache. Acquired tokens are cached by the credential instance. Token lifetime and refreshing is handled automatically. Where possible, reuse credential instances to optimize cache effectiveness.

public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)

Parameters

requestContext TokenRequestContext

The details of the authentication request.

cancellationToken CancellationToken

A CancellationToken controlling the request lifetime

Returns

ValueTask<AccessToken>

An Azure.Core.AccessToken which can be used to authenticate service client calls