Class TokenProvider | Azure SDK for Net
James Stevens
Published Feb 16, 2026
This abstract base class can be extended to implement additional token providers.
Inheritance
TokenProvider
Namespace: Microsoft.Azure.EventHubs
Assembly: Microsoft.Azure.EventHubs.dll
Syntax
public abstract class TokenProvider : Microsoft.Azure.EventHubs.ITokenProvider Constructors
TokenProvider()
Declaration
protected TokenProvider (); Methods
CreateAzureActiveDirectoryTokenProvider(AzureActiveDirectoryTokenProvider+AuthenticationCallback, String, Object)
Creates an Azure Active Directory token provider.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateAzureActiveDirectoryTokenProvider (Microsoft.Azure.EventHubs.AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback, string authority, object state = null); Parameters
Returns
CreateManagedIdentityTokenProvider()
Creates Azure Managed Identity token provider.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateManagedIdentityTokenProvider (); Returns
CreateSharedAccessSignatureTokenProvider(String)
Construct a TokenProvider based on a sharedAccessSignature.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateSharedAccessSignatureTokenProvider (string sharedAccessSignature); Parameters
| String sharedAccessSignature The shared access signature |
Returns
| TokenProvider A TokenProvider initialized with the shared access signature |
CreateSharedAccessSignatureTokenProvider(String, String)
Construct a TokenProvider based on the provided Key Name and Shared Access Key.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateSharedAccessSignatureTokenProvider (string keyName, string sharedAccessKey); Parameters
| String keyName The key name of the corresponding SharedAccessKeyAuthorizationRule. |
| String sharedAccessKey The key associated with the SharedAccessKeyAuthorizationRule |
Returns
| TokenProvider A TokenProvider initialized with the provided RuleId and Password |
CreateSharedAccessSignatureTokenProvider(String, String, TokenScope)
Construct a TokenProvider based on the provided Key Name and Shared Access Key.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateSharedAccessSignatureTokenProvider (string keyName, string sharedAccessKey, Microsoft.Azure.EventHubs.TokenScope tokenScope); Parameters
| String keyName The key name of the corresponding SharedAccessKeyAuthorizationRule. |
| String sharedAccessKey The key associated with the SharedAccessKeyAuthorizationRule |
| TokenScope tokenScope The tokenScope of tokens to request. |
Returns
| TokenProvider A TokenProvider initialized with the provided RuleId and Password |
CreateSharedAccessSignatureTokenProvider(String, String, TimeSpan)
Construct a TokenProvider based on the provided Key Name and Shared Access Key.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateSharedAccessSignatureTokenProvider (string keyName, string sharedAccessKey, TimeSpan tokenTimeToLive); Parameters
| String keyName The key name of the corresponding SharedAccessKeyAuthorizationRule. |
| String sharedAccessKey The key associated with the SharedAccessKeyAuthorizationRule |
| TimeSpan tokenTimeToLive The token time to live |
Returns
| TokenProvider A TokenProvider initialized with the provided RuleId and Password |
CreateSharedAccessSignatureTokenProvider(String, String, TimeSpan, TokenScope)
Construct a TokenProvider based on the provided Key Name and Shared Access Key.
Declaration
public static Microsoft.Azure.EventHubs.TokenProvider CreateSharedAccessSignatureTokenProvider (string keyName, string sharedAccessKey, TimeSpan tokenTimeToLive, Microsoft.Azure.EventHubs.TokenScope tokenScope); Parameters
| String keyName The key name of the corresponding SharedAccessKeyAuthorizationRule. |
| String sharedAccessKey The key associated with the SharedAccessKeyAuthorizationRule |
| TimeSpan tokenTimeToLive 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)
Declaration
public abstract System.Threading.Tasks.Task<Microsoft.Azure.EventHubs.SecurityToken> GetTokenAsync (string appliesTo, TimeSpan timeout); Parameters
| String appliesTo The URI which the access token applies to |
| TimeSpan timeout The time span that specifies the timeout value for the message that gets the security token |