ApiKeyManager

Class

Used to authenticate methods in ArcGIS REST JS with an API keys. The instance of ApiKeyManager can be passed to IRequestOptions.authentication to authenticate requests.

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

const apiKey = new ApiKeyManager.fromKey("...");

In most cases however the API key can be passed directly to the IRequestOptions.authentication.

Implements

Constructors

constructor

Class Constructor
new ApiKeyManager(optionsIApiKeyOptions): ApiKeyManager
Parameters
ParameterType
options
IApiKeyOptions
Returns 
ApiKeyManager

Properties

PropertyTypeNotes
string

The current portal the user is authenticated with.

portal

Class Property
portal: string = "https://www.arcgis.com/sharing/rest"

The current portal the user is authenticated with.

Methods

MethodReturnsNotes
Promise<string>

Gets a token (the API Key).

fromKey(apiKey)

The preferred method for creating an instance of ApiKeyManager.

getToken

Class Method
getToken(urlstring): Promise<string>

Gets a token (the API Key).

Parameters
ParameterType
url
string
Returns 
Promise<string>

fromKey

static
Class Method
fromKey(apiKeystring): ApiKeyManager

The preferred method for creating an instance of ApiKeyManager.

Parameters
ParameterType
apiKey
string
Returns 
ApiKeyManager

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