getApiKey
FunctiongetApiKey(requestOptions: IGetApiKeyOptions): Promise<IApiKeyResponse>
Used to retrieve the API key with given itemId
. See the security and authentication for more information about API key.
import { getApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';
import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
username: "xyz_usrName",
password: "xyz_pw"
});
getApiKey({
itemId: "xyz_itemId",
authentication: authSession
}).then((retrievedAPIKey: IApiKeyResponse) => {
// => {apiKey: "xyz_key", item: {tags: ["xyz_tag1", "xyz_tag2"], ...}, ...}
}).catch(e => {
// => an exception object
});
Parameters
Parameter | Type | Notes |
---|---|---|
request | IGetApiKeyOptions | Options for |
Returns
Promise<IApiKeyResponse>
A Promise that will resolve to an IApiKeyResponse
object representing successfully retrieved API key.