TokenCredential class

TokenCredential is a Credential used to generate a TokenCredentialPolicy. Renew token by setting a new token string value to token property.

Example

const tokenCredential = new TokenCredential("clientId", "token"); const pipeline = MapsURL.newPipeline(tokenCredential);

const searchURL = new SearchURL(pipeline);

// Set up a timer to refresh the token const timerID = setInterval(() => { // Update token by accessing to public tokenCredential.token tokenCredential.token = "updatedToken"; // WARNING: Timer must be manually stopped! It will forbid GC of tokenCredential if (shouldStop()) { clearInterval(timerID); } }, 60 * 60 * 1000); // Set an interval time before your token expired

Extends

Constructors

TokenCredential(string, string)

Creates an instance of TokenCredential.

Properties

clientId

Mutable client ID value. You can set a new ID value to this property, for example, when using a new token for another Azure Maps account.

token

Mutable token value. You can set a renewed token value to this property, for example, when an OAuth token is expired.

Methods

create(RequestPolicy, RequestPolicyOptions)

Creates a TokenCredentialPolicy object.

Constructor Details

TokenCredential(string, string)

Creates an instance of TokenCredential.

new TokenCredential(clientId: string, token: string)

Parameters

clientId

string

token

string

Property Details

clientId

Mutable client ID value. You can set a new ID value to this property, for example, when using a new token for another Azure Maps account.

clientId: string

Property Value

string

token

Mutable token value. You can set a renewed token value to this property, for example, when an OAuth token is expired.

token: string

Property Value

string

Method Details

create(RequestPolicy, RequestPolicyOptions)

Creates a TokenCredentialPolicy object.

function create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): TokenCredentialPolicy

Parameters

nextPolicy

RequestPolicy

options

RequestPolicyOptions

Returns