AppCredentials class
General AppCredentials auth implementation and cache. Supports any ADAL client credential flow. Subclasses can implement refreshToken to acquire the token.
Constructors
App |
Initializes a new instance of the AppCredentials class. |
Properties
app |
|
o |
Gets the OAuth endpoint to use. Sets the OAuth endpoint to use. |
o |
Gets the OAuth scope to use. Sets the OAuth scope to use. |
token |
Methods
get |
Gets an OAuth access token. |
is |
Checks if the service url is for a trusted host or not. |
sign |
Apply the credentials to the HTTP request. |
trust |
Adds the host of service url to trusted hosts. If expiration time is not provided, the expiration date will be current (utc) date + 1 day. |
Constructor Details
AppCredentials(string, string, string)
Initializes a new instance of the AppCredentials class.
new AppCredentials(appId: string, channelAuthTenant?: string, oAuthScope?: string)
Parameters
- appId
-
string
The App ID.
- channelAuthTenant
-
string
Optional. The oauth token tenant.
- oAuthScope
-
string
The scope for the token.
Property Details
appId
appId: string
Property Value
string
oAuthEndpoint
Gets the OAuth endpoint to use. Sets the OAuth endpoint to use.
string oAuthEndpoint
Property Value
string
The OAuthEndpoint to use.
oAuthScope
Gets the OAuth scope to use. Sets the OAuth scope to use.
string oAuthScope
Property Value
string
The OAuth scope to use.
tokenCacheKey
tokenCacheKey: string
Property Value
string
Method Details
getToken(boolean)
Gets an OAuth access token.
function getToken(forceRefresh?: boolean): Promise<string>
Parameters
- forceRefresh
-
boolean
True to force a refresh of the token; or false to get a cached token if it exists.
Returns
Promise<string>
A Promise that represents the work queued to execute.
Remarks
If the promise is successful, the result contains the access token string.
isTrustedServiceUrl(string)
Warning
This API is now deprecated.
Checks if the service url is for a trusted host or not.
static function isTrustedServiceUrl(serviceUrl: string): boolean
Parameters
- serviceUrl
-
string
The service url
Returns
boolean
True if the host of the service url is trusted; False otherwise.
signRequest(WebResource)
Apply the credentials to the HTTP request.
function signRequest(webResource: WebResource): Promise<WebResource>
Parameters
- webResource
-
WebResource
The WebResource HTTP request.
Returns
Promise<WebResource>
A Promise representing the asynchronous operation.
trustServiceUrl(string, Date)
Warning
This API is now deprecated.
Adds the host of service url to trusted hosts. If expiration time is not provided, the expiration date will be current (utc) date + 1 day.
static function trustServiceUrl(serviceUrl: string, expiration?: Date)
Parameters
- serviceUrl
-
string
The service url
- expiration
-
Date