Table of Contents

Class InteractiveBrowserCredential

Namespace
Azure.Identity
Assembly
Azure.Identity.dll

A Azure.Core.TokenCredential implementation which launches the system default browser to interactively authenticate a user, and obtain an access token. The browser will only be launched to authenticate the user once, then will silently acquire access tokens through the users refresh token as long as it's valid.

public class InteractiveBrowserCredential : TokenCredential
Inheritance
InteractiveBrowserCredential

Constructors

InteractiveBrowserCredential()

Creates a new InteractiveBrowserCredential with the specified options, which will authenticate users.

public InteractiveBrowserCredential()

InteractiveBrowserCredential(InteractiveBrowserCredentialOptions)

Creates a new InteractiveBrowserCredential with the specified options, which will authenticate users with the specified application.

public InteractiveBrowserCredential(InteractiveBrowserCredentialOptions options)

Parameters

options InteractiveBrowserCredentialOptions

The client options for the newly created InteractiveBrowserCredential.

Methods

Authenticate(TokenRequestContext, CancellationToken)

Interactively authenticates a user via the default browser. The resulting AuthenticationRecord will automatically be used in subsequent calls to GetToken(TokenRequestContext, CancellationToken).

public virtual AuthenticationRecord Authenticate(TokenRequestContext requestContext, CancellationToken cancellationToken = default)

Parameters

requestContext TokenRequestContext

The details of the authentication request.

cancellationToken CancellationToken

A CancellationToken controlling the request lifetime.

Returns

AuthenticationRecord

The AuthenticationRecord of the authenticated account.

Authenticate(CancellationToken)

Interactively authenticates a user via the default browser.

public virtual AuthenticationRecord Authenticate(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken controlling the request lifetime.

Returns

AuthenticationRecord

The result of the authentication request, containing the acquired Azure.Core.AccessToken, and the AuthenticationRecord which can be used to silently authenticate the account.

AuthenticateAsync(TokenRequestContext, CancellationToken)

Interactively authenticates a user via the default browser.

public virtual Task<AuthenticationRecord> AuthenticateAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)

Parameters

requestContext TokenRequestContext

The details of the authentication request.

cancellationToken CancellationToken

A CancellationToken controlling the request lifetime.

Returns

Task<AuthenticationRecord>

The AuthenticationRecord of the authenticated account.

AuthenticateAsync(CancellationToken)

Interactively authenticates a user via the default browser. The resulting AuthenticationRecord will automatically be used in subsequent calls to GetTokenAsync(TokenRequestContext, CancellationToken).

public virtual Task<AuthenticationRecord> AuthenticateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken controlling the request lifetime.

Returns

Task<AuthenticationRecord>

The result of the authentication request, containing the acquired Azure.Core.AccessToken, and the AuthenticationRecord which can be used to silently authenticate the account.

GetToken(TokenRequestContext, CancellationToken)

Obtains an Azure.Core.AccessToken token for a user account silently if the user has already authenticated, otherwise the default browser is launched to authenticate the user. 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, otherwise the default browser is launched to authenticate the user. 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.