Access tokens

What is an access token?

An access token is an authorization string that provides secure access to ArcGIS resources. Your app must present an access token whenever it makes an authenticated request to location services or private content. They define the scope of privileges available to your application, and their properties vary based on the type of authentication used to obtain them. Access tokens are always associated with an ArcGIS account, and service usage with the token will be billed to that account's ArcGIS subscription.

Use dark colors for code blocksCopy
1
AAPK033d7ed7a735484ebc15eb6d787d25a94MP1Gsh6eCLSeruJEVU0gD6CFSGqgVdz1naRx9QWKjOkdwYGLDJFJxIF_MRTAwLk
A sample access token (API key)

You can get an access token by implementing a type of authentication in your app. Different types of authentication result in access tokens with different privileges.

Types of access tokens

There are two types of access tokens that have different durations.

Type of tokenType of authenticationDescription
PermanentAPI key authenticationPermanent API keys do not expire. They are created, managed, and deleted in the developer dashboard.
Short-livedUser authentication, app credential authenticationExpires after a set amount of time, usually 30 minutes by default. Privileges vary based on the type of authentication used to obtain them. Short-lived tokens are usually paired with refresh tokens.

Access token privileges

Access tokens have different privileges depending on the method used to obtain them. The following table compares the privileges of access tokens from different types of authentication.

API key access tokensUser authentication access tokensApp credential authentication access tokens
Ready-to-use services
Public content
Secure content1
Subscriber and premium content
Content management services2
Full supportPartial supportNo support
  • 1. ArcGIS Developer subscriptions only
  • 2. ArcGIS Developer subscriptions only, limited

Access tokens from user authentication are associated with a user's ArcGIS account and access services and content on their behalf. The level of access authorized to a user authentication token is determined by the associated account's roles and privileges.

How to use an access token

You can make use an access token to make an authenticated request to ArcGIS resources. To make authenticated requests to location services, you need to set the token parameter of the REST API request.

Use dark colors for code blocksCopy
1
https://<LOCATION_SERVICE_URL>?token=<ACCESS_TOKEN>
Sample REST API request to a location service that is authenticated using an access token

You can also make requests to ArcGIS REST APIs by using an ArcGIS Maps SDK.

Code examples

The following code examples show how to use access tokens to authenticate REST API requests to ArcGIS resources.

Access a basemap style

This example accesses the ArcGIS Outdoor basemap style from the basemap styles service.

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
curl https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/arcgis/outdoor? \
-d "token=<ACCESS_TOKEN>"

Perform geocoding

This example performs a forward geocode by making a request to 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=<ACCESS_TOKEN>"

Access a feature service

This example retrieves features from a feature service.

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
5
curl https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/LA_County_Parcels/FeatureServer/0/query? \
-d "where=1=1" \
-d "outFields=*" \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"

Get item details

This example accesses a private item hosted in ArcGIS.com and retrieves its properties.

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=<ACCESS_TOKEN>'

Tutorials

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