Class AzurePipelinesCredential
Credential which authenticates using an Azure Pipelines service connection.
public class AzurePipelinesCredential : TokenCredential
- Inheritance
-
AzurePipelinesCredential
Constructors
AzurePipelinesCredential()
Protected constructor for mocking.
protected AzurePipelinesCredential()
AzurePipelinesCredential(string, string, string, string, AzurePipelinesCredentialOptions)
Creates a new instance of the AzurePipelinesCredential.
public AzurePipelinesCredential(string tenantId, string clientId, string serviceConnectionId, string systemAccessToken, AzurePipelinesCredentialOptions options = null)
Parameters
tenantId
stringThe tenant ID for the service connection.
clientId
stringThe client ID for the service connection.
serviceConnectionId
stringThe service connection Id for the service connection associated with the pipeline.
systemAccessToken
stringThe pipeline's System.AccessToken value.
options
AzurePipelinesCredentialOptionsAn instance of AzurePipelinesCredentialOptions.
Exceptions
- ArgumentNullException
When
systemAccessToken
is null.
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.