Share via


UserTokenCredentials class

Extends

Constructors

UserTokenCredentials(string, string, string, string, TokenAudience, Environment, TokenCache)

Creates a new UserTokenCredentials object.

Properties

password
username

Inherited Properties

authContext
clientId
domain
environment
tokenAudience
tokenCache

Methods

getToken()

Tries to get the token from cache initially. If that is unsuccessful then it tries to get the token from ADAL.

Inherited Methods

setDomain(string)
signRequest(WebResource)

Signs a request with the Authentication header.

Constructor Details

UserTokenCredentials(string, string, string, string, TokenAudience, Environment, TokenCache)

Creates a new UserTokenCredentials object.

new UserTokenCredentials(clientId: string, domain: string, username: string, password: string, tokenAudience?: TokenAudience, environment?: Environment, tokenCache?: TokenCache)

Parameters

clientId

string

The active directory application client id. See Active Directory Quickstart for .Net for an example.

domain

string

The domain or tenant id containing this application.

username

string

The user name for the Organization Id account.

password

string

The password for the Organization Id account.

tokenAudience
TokenAudience

The audience for which the token is requested. Valid values are 'graph', 'batch', or any other resource like 'https://vault.azure.net/'. If tokenAudience is 'graph' then domain should also be provided and its value should not be the default 'common' tenant. It must be a string (preferably in a guid format).

environment
Environment

The azure environment to authenticate with.

tokenCache

TokenCache

The token cache. Default value is the MemoryCache object from adal.

Property Details

password

password: string

Property Value

string

username

username: string

Property Value

string

Inherited Property Details

authContext

authContext: AuthenticationContext

Property Value

AuthenticationContext

Inherited From TokenCredentialsBase.authContext

clientId

clientId: string

Property Value

string

Inherited From TokenCredentialsBase.clientId

domain

domain: string

Property Value

string

Inherited From TokenCredentialsBase.domain

environment

environment: Environment

Property Value

Inherited From TokenCredentialsBase.environment

tokenAudience

tokenAudience?: string

Property Value

string

Inherited From TokenCredentialsBase.tokenAudience

tokenCache

tokenCache: TokenCache

Property Value

TokenCache

Inherited From TokenCredentialsBase.tokenCache

Method Details

getToken()

Tries to get the token from cache initially. If that is unsuccessful then it tries to get the token from ADAL.

function getToken(): Promise<TokenResponse>

Returns

Promise<TokenResponse>

The tokenResponse (tokenType and accessToken are the two important properties).

Inherited Method Details

setDomain(string)

function setDomain(domain: string)

Parameters

domain

string

Inherited From TokenCredentialsBase.setDomain

signRequest(WebResource)

Signs a request with the Authentication header.

function signRequest(webResource: WebResource): Promise<WebResource>

Parameters

webResource
WebResource

The WebResource to be signed.

Returns

Promise<WebResource>

Inherited From TokenCredentialsBase.signRequest