ArcGIS uses token-based authentication. All service requests made to secure resources
The general steps to implement authentication in your application are:
1. Create developer credentials
The first step in authentication is to create a set of developer credentials
API key authentication
2. Get an access token
The next step is to get an access token
3. Make a request
Once you have an access token
Mapping APIs
Display a basemap
If you use API key authentication
The examples below show how to use an API key to access the basemap styles service
esriConfig.apiKey = "YOUR_ACCESS_TOKEN";
const map = new Map({
basemap: "arcgis/topographic", // Basemap layer
});
const view = new MapView({
map: map,
center: [-118.805, 34.027],
zoom: 13, // scale: 72223.819286
container: "viewDiv",
constraints: {
snapToZoom: false,
},
});
ArcGIS REST APIs
Access tokens returned from all three types of authentication can be used in REST API requests. To make a direct request to ArcGIS resources, you can use an HTTP request and include the access token as the token parameter. The format to access most REST API endpoints is as follows:
https://<RESOURCE_URL>?token=<YOUR_ACCESS_TOKEN>Geocode an address
This example shows how to authenticate a request to the geocoding service
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates \
-d "f=pjson" \
-d "address=1600 Pennsylvania Ave NW, DC" \
-d "token=<YOUR_ACCESS_TOKEN>"Get item details
This example shows how to authenticate to get the details of an item
curl https://www.arcgis.com/sharing/rest/content/items/<ITEM_ID> \
-d 'f=pjson' \
-d 'token=<YOUR_ACCESS_TOKEN>'Tutorials
Create an API key
Create and configure API key credentials to get a long-lived API key access token.
Sign in with user authentication
Create an application that requires users to sign in with an ArcGIS account