How to use authentication

ArcGIS uses token-based authentication. All service requests made to secure resources must include an access token for authorization.

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. Developer credentials contain the properties and values required to get an access token, and allow you to configure the privileges of the token to define the services and items it can access.

API key authentication requires a set of API key credentials. The steps to create API key credentials are:

  1. Sign in to your ArcGIS portal.

  2. Click Content > My content > New item and select Developer credentials.

  3. In the Credential types menu, select API key credentials.

  4. Set the credential privileges to determine the operations your access token will be authorized to perform.

  5. Set the credential item access privileges to determine the items your access token will be authorized to access.

  6. Review your selections and, when you are ready, click Generate token. Save the access token as you will not be able to view it again.

2. Get an access token

The next step is to get an access token by implementing a type of authentication. The implementation details depend on the type of authentication you choose:

API key authentication flow
The API key authentication workflow

3. Make a request

Once you have an access token, you can use it in your application to make requests to secure resources.

Mapping APIs

Display a basemap

If you are using an ArcGIS API, the API key value is typically set once when the application is initialized and is applied every time a request is made to a location service.

The examples below show how to use an API key to access the basemap styles service.

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for .NETArcGIS Maps SDK for KotlinArcGIS Maps SDK for SwiftArcGIS Maps SDK for JavaArcGIS Maps SDK for QtArcGIS API for PythonEsri LeafletMapLibre GL JSOpenLayers
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
      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

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:

Use dark colors for code blocksCopy
1
https://<RESOURCE_URL>?token=<YOUR_ACCESS_TOKEN>

Geocode an address

This example shows how to geocode an address with the geocoding service.

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
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 get the details of an item from your organization's portal service.

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
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 OAuth credentials for app authentication

Create and configure OAuth credentials to set up app authentication.


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