import Credential from "@arcgis/core/identity/Credential.js";const Credential = await $arcgis.import("@arcgis/core/identity/Credential.js");- Inheritance:
- Credential→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.0
Represents a credential object used to access a secure ArcGIS resource.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
isAdmin
- Type
- boolean
Indicates that this credential was created to access the ArcGIS Server Administrator REST API.
oAuthState
- Type
- any
The Identity Manager's
IdentityManagerBase.setOAuthRedirectionHandler()
returns an object that contains a state property. This information is returned for this property.
ssl
- Type
- boolean
Indicates whether the resources accessed using this credential should be fetched over HTTPS protocol.
token
- Type
- string
Token generated by the token service using the specified userId and password.
Methods
| Method | Signature | Class |
|---|---|---|
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
- 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.
- Returns
- void
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
- 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.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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).Property Type Description remove Function When 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
- 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.
Events
| Name | Type |
|---|---|
destroy
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.
token-change
token-change: CustomEvent<void> Fires when the token associated with the credential is updated or changed.