Table of Contents

Class TokenProvider

Namespace
Microsoft.Azure.ServiceBus.Primitives
Assembly
Microsoft.Azure.ServiceBus.dll

This abstract base class can be extended to implement additional token providers.

public abstract class TokenProvider : ITokenProvider
Inheritance
TokenProvider
Implements
Derived
Inherited Members

Constructors

TokenProvider()

protected TokenProvider()

Methods

CreateAadTokenProvider(AuthenticationContext, ClientAssertionCertificate)

Creates an Azure Active Directory token provider.

public static TokenProvider CreateAadTokenProvider(AuthenticationContext authContext, ClientAssertionCertificate clientAssertionCertificate)

Parameters

authContext AuthenticationContext

AuthenticationContext for AAD.

clientAssertionCertificate ClientAssertionCertificate

The client assertion certificate credential.

Returns

TokenProvider

The TokenProvider for returning Json web token.

CreateAadTokenProvider(AuthenticationContext, ClientCredential)

Creates an Azure Active Directory token provider.

public static TokenProvider CreateAadTokenProvider(AuthenticationContext authContext, ClientCredential clientCredential)

Parameters

authContext AuthenticationContext

AuthenticationContext for AAD.

clientCredential ClientCredential

The app credential.

Returns

TokenProvider

The TokenProvider for returning Json web token.

CreateAadTokenProvider(AuthenticationContext, string, Uri, IPlatformParameters, UserIdentifier)

Creates an Azure Active Directory token provider.

public static TokenProvider CreateAadTokenProvider(AuthenticationContext authContext, string clientId, Uri redirectUri, IPlatformParameters platformParameters, UserIdentifier userIdentifier = null)

Parameters

authContext AuthenticationContext

AuthenticationContext for AAD.

clientId string

ClientId for AAD.

redirectUri Uri

The redirectUri on Client App.

platformParameters IPlatformParameters

Platform parameters

userIdentifier UserIdentifier

User Identifier

Returns

TokenProvider

The TokenProvider for returning Json web token.

CreateManagedServiceIdentityTokenProvider()

Creates Azure Managed Service Identity token provider.

public static TokenProvider CreateManagedServiceIdentityTokenProvider()

Returns

TokenProvider

The TokenProvider for returning Json web token.

CreateSharedAccessSignatureTokenProvider(string)

Construct a TokenProvider based on a sharedAccessSignature.

public static TokenProvider CreateSharedAccessSignatureTokenProvider(string sharedAccessSignature)

Parameters

sharedAccessSignature string

The shared access signature

Returns

TokenProvider

A TokenProvider initialized with the shared access signature

Remarks

GetTokenAsync(string, TimeSpan) parameters will not be used to manipulate target URL and token TTL.

CreateSharedAccessSignatureTokenProvider(string, string)

Construct a TokenProvider based on the provided Key Name and Shared Access Key.

public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey)

Parameters

keyName string

The key name of the corresponding SharedAccessKeyAuthorizationRule.

sharedAccessKey string

The key associated with the SharedAccessKeyAuthorizationRule

Returns

TokenProvider

A TokenProvider initialized with the provided RuleId and Password

Remarks

Default token TTL is 1 hour and token scope is at entity level.

CreateSharedAccessSignatureTokenProvider(string, string, TokenScope)

Construct a TokenProvider based on the provided Key Name and Shared Access Key.

public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey, TokenScope tokenScope)

Parameters

keyName string

The key name of the corresponding SharedAccessKeyAuthorizationRule.

sharedAccessKey string

The key associated with the SharedAccessKeyAuthorizationRule

tokenScope TokenScope

The tokenScope of tokens to request.

Returns

TokenProvider

A TokenProvider initialized with the provided keyName and key

Remarks

Default token TTL is 1 hour.

CreateSharedAccessSignatureTokenProvider(string, string, TimeSpan)

Construct a TokenProvider based on the provided Key Name and Shared Access Key.

public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey, TimeSpan tokenTimeToLive)

Parameters

keyName string

The key name of the corresponding SharedAccessKeyAuthorizationRule.

sharedAccessKey string

The key associated with the SharedAccessKeyAuthorizationRule

tokenTimeToLive TimeSpan

The token time to live

Returns

TokenProvider

A TokenProvider initialized with the provided keyName and key.

CreateSharedAccessSignatureTokenProvider(string, string, TimeSpan, TokenScope)

Construct a TokenProvider based on the provided Key Name and Shared Access Key.

public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey, TimeSpan tokenTimeToLive, TokenScope tokenScope)

Parameters

keyName string

The key name of the corresponding SharedAccessKeyAuthorizationRule.

sharedAccessKey string

The key associated with the SharedAccessKeyAuthorizationRule

tokenTimeToLive TimeSpan

The token time to live

tokenScope TokenScope

The tokenScope of tokens to request.

Returns

TokenProvider

A TokenProvider initialized with the provided RuleId and Password

GetTokenAsync(string, TimeSpan)

Gets a SecurityToken for the given audience and duration.

public abstract Task<SecurityToken> GetTokenAsync(string appliesTo, TimeSpan timeout)

Parameters

appliesTo string

The URI which the access token applies to

timeout TimeSpan

The timeout value for how long it takes to get the security token (not the token time to live).

Returns

Task<SecurityToken>

Remarks

This parameter timeout is here for compatibility, but is not currently used.