ApplicationCredentialsManager

Class

Used to authenticate methods in ArcGIS REST JS with oAuth 2.0 application credentials. The instance of ApplicationCredentialsManager can be passed to IRequestOptions.authentication to authenticate requests.

Use dark colors for code blocksCopy
1
2
3
4
5
6
import { ApplicationCredentialsManager } from '@esri/arcgis-rest-request';

const session = ApplicationCredentialsManager.fromCredentials({
  clientId: "abc123",
  clientSecret: "••••••"
})

Implements

Inheritance: ApplicationCredentialsManagerAuthenticationManagerBase

Constructors

constructor

Class Constructor
new ApplicationCredentialsManager(optionsIApplicationCredentialsManagerOptions): ApplicationCredentialsManager
Parameters
Returns 
ApplicationCredentialsManager

Properties

PropertyTypeNotes
string

Defaults to 'https://www.arcgis.com/sharing/rest'.

portal

Class Property
portal: string

Defaults to 'https://www.arcgis.com/sharing/rest'.

Accessors

AccessorReturnsNotes
get username()
string

The username of the currently authenticated user.

username

Class Accessor
get username(): string

The username of the currently authenticated user.

Returns 
string

Methods

Hide inherited methods
MethodReturnsNotes
void

Clear the cached user infornation. Usefull to ensure that the most recent user information from AuthenticationManagerBase.getUser is used.

getToken(url, requestOptions?)
Promise<string>

Returns the proper token for a given URL and request options.

getUser(requestOptions?)
inherited
Promise<IUser>

Returns information about the currently logged in user. Subsequent calls will not result in additional web traffic.

getUsername()
inherited
Promise<string>

Returns the username for the currently logged in user. Subsequent calls will not result in additional web traffic. This is also used internally when a username is required for some requests but is not present in the options.

Optional. Refresh the stored credentials.

refreshToken(requestOptions?)
Promise<string>

Preferred method for creating an ApplicationCredentialsManager

clearCachedUserInfo

inherited
Class Method
clearCachedUserInfo(): void

Clear the cached user infornation. Usefull to ensure that the most recent user information from AuthenticationManagerBase.getUser is used.

Returns 
void
Inherited from AuthenticationManagerBase.clearCachedUserInfo

getToken

Class Method
getToken(urlstring, requestOptions?ITokenRequestOptions): Promise<string>

Returns the proper token for a given URL and request options.

Parameters
ParameterType
url
string
requestOptions
ITokenRequestOptions
Returns 
Promise<string>

getUser

inherited
Class Method
getUser(requestOptions?IRequestOptions): Promise<IUser>

Returns information about the currently logged in user. Subsequent calls will not result in additional web traffic.

Use dark colors for code blocksCopy
1
2
3
4
manager.getUser()
  .then(response => {
    console.log(response.role); // "org_admin"
  })
Parameters
ParameterTypeNotes
requestOptions
IRequestOptions

Options for the request. NOTE: rawResponse is not supported by this operation.

Returns 
Promise<IUser>

A Promise that will resolve with the data from the response.

Inherited from AuthenticationManagerBase.getUser

getUsername

inherited
Class Method
getUsername(): Promise<string>

Returns the username for the currently logged in user. Subsequent calls will not result in additional web traffic. This is also used internally when a username is required for some requests but is not present in the options.

Use dark colors for code blocksCopy
1
2
3
4
manager.getUsername()
  .then(response => {
    console.log(response); // "casey_jones"
  })
Returns 
Promise<string>
Inherited from AuthenticationManagerBase.getUsername

refreshCredentials

Class Method
refreshCredentials(): Promise<ApplicationCredentialsManager>

Optional. Refresh the stored credentials.

Returns 
Promise<ApplicationCredentialsManager>

refreshToken

Class Method
refreshToken(requestOptions?ITokenRequestOptions): Promise<string>
Parameters
ParameterType
requestOptions
ITokenRequestOptions
Returns 
Promise<string>

fromCredentials

static
Class Method
fromCredentials(optionsIApplicationCredentialsManagerOptions): ApplicationCredentialsManager

Preferred method for creating an ApplicationCredentialsManager

Parameters
Returns 
ApplicationCredentialsManager

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.