Skip to content
import Credential from "@arcgis/core/identity/Credential.js";
Inheritance:
CredentialAccessor
Since
ArcGIS Maps SDK for JavaScript 4.0

Represents a credential object used to access a secure ArcGIS resource.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

expires

Property
Type
number | null

Token expiration time specified as number of milliseconds since 1 January 1970 00:00

UTC.

See also

isAdmin

Property
Type
boolean

Indicates that this credential was created to access the ArcGIS Server Administrator REST API.

oAuthState

Property
Type
any

The Identity Manager's IdentityManagerBase.setOAuthRedirectionHandler() returns an object that contains a state property. This information is returned for this property.

scope

Property
Type
"portal" | "server"

The scope of the credential.

server

Property
Type
string

The server url.

ssl

Property
Type
boolean

Indicates whether the resources accessed using this credential should be fetched over HTTPS protocol.

token

Property
Type
string

Token generated by the token service using the specified userId and password.

userId

Property
Type
string

User associated with the Credential object.

Methods

MethodSignatureClass
destroy(): void
emit
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
hasEventListener
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
refreshToken(): Promise<any> | undefined

destroy

Method
Signature
destroy (): void

Destroys the credential. When the credential is destroyed, you should remove any map layers that are using this credential. Any tokens generated via OAuth will automatically be revoked.

See also
Returns
void

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin
Since
ArcGIS Maps SDK for JavaScript 4.5

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters
ParameterTypeDescriptionRequired
type
Type

An event or an array of events to listen for.

listener
EventedCallback<this["@eventTypes"][Type]>

The function to call when the event fires.

Returns
ResourceHandle

Returns an event handler with a remove() method that should be called to stop listening for the event(s).

PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
Example
view.on("click", function(event){
// event is the event handle returned after the event fires.
console.log(event.mapPoint);
});

refreshToken

Method
Signature
refreshToken (): Promise<any> | undefined

Generates a new token and updates the Credential's token property with the newly acquired token. Tokens are typically kept valid using a timer that automatically triggers a refresh before the token expires. Use this method in cases where the timer has been delayed or stopped.

Returns
Promise<any> | undefined

Events

destroy

Event
destroy: CustomEvent<void>

Fires when a credential object is destroyed. After the credential is destroyed, remove any map layers that use this credential. Any tokens generated via OAuth will automatically be revoked.

See also
bubbles composed cancelable

token-change

Event
token-change: CustomEvent<void>

Fires when the token associated with the credential is updated or changed.

bubbles composed cancelable

Type definitions