SasTokenProvider class

Constructors

SasTokenProvider(string, string, string, number, number)

Initializes a new instance of SasTokenProvider

Properties

key

The secret value associated with the above EventHub/ServiceBus key.

keyName

The name of the EventHub/ServiceBus key.

namespace

The namespace of the EventHub/ServiceBus instance.

tokenRenewalMarginInSeconds

The number of seconds within which it is good to renew the token. Default = 900 seconds (15 minutes).

tokenValidTimeInSeconds

The number of seconds for which the token is valid. Default = 3600 seconds (1 hour).

Methods

fromConnectionString(string)

Creates a token provider from the EventHub/ServiceBus connection string;

getToken(string)

Gets the sas token for the specified audience

Constructor Details

SasTokenProvider(string, string, string, number, number)

Initializes a new instance of SasTokenProvider

new SasTokenProvider(namespace: string, keyName: string, key: string, tokenValidTimeInSeconds?: number, tokenRenewalMarginInSeconds?: number)

Parameters

namespace

string

The namespace of the EventHub/ServiceBus instance.

keyName

string

The name of the EventHub/ServiceBus key.

key

string

The secret value associated with the above EventHub/ServiceBus key

tokenValidTimeInSeconds

number

tokenRenewalMarginInSeconds

number

Property Details

key

The secret value associated with the above EventHub/ServiceBus key.

key: string

Property Value

string

keyName

The name of the EventHub/ServiceBus key.

keyName: string

Property Value

string

namespace

The namespace of the EventHub/ServiceBus instance.

namespace: string

Property Value

string

tokenRenewalMarginInSeconds

The number of seconds within which it is good to renew the token. Default = 900 seconds (15 minutes).

tokenRenewalMarginInSeconds: number

Property Value

number

tokenValidTimeInSeconds

The number of seconds for which the token is valid. Default = 3600 seconds (1 hour).

tokenValidTimeInSeconds: number

Property Value

number

Method Details

fromConnectionString(string)

Creates a token provider from the EventHub/ServiceBus connection string;

static function fromConnectionString(connectionString: string): SasTokenProvider

Parameters

connectionString

string

The EventHub/ServiceBus connection string

Returns

getToken(string)

Gets the sas token for the specified audience

function getToken(audience?: string): Promise<TokenInfo>

Parameters

audience

string

The audience for which the token is desired. If not provided then the Endpoint from the connection string will be applied.

Returns

Promise<TokenInfo>