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.
AAPTKUgfudpnh_cXrZ7wRiqGE4q0VCQENKpafTPqVh27cldNPiqORWEyVueCmI67s3ebSNEYl0Sn3IitIyf18X8PxF3N8m9ZE30i5iwGHtGfnv6-DoKA-C8-lJ9GM30s-Wxn75jLBdnQnMjIgwVXEjIoualIMSfk4IWraDv3GMV8XP3fAUA73P23Vfs-THx2QjfDNVD3iuGCqLG0udK_TVLchskcBFVbsj1PRWXGcFaKKzdPkwWMXps_4P_cZEBAZdImAT1_L1aY2CIy
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 different types of access tokens that have different durations.
Type of token | Type of authentication | Description |
---|---|---|
API token | API key authentication | A static, long-lived API key valid for up to one year. They are created, managed, and deleted using API key credentials. |
User token | User authentication | Expires after a set amount of time, 30 minutes by default (max 2 weeks). A new token is generated for each user that signs in to a custom application with user authentication. |
App token | App authentication | Expires after 2 weeks. They are generated using a client and client from OAuth credentials. |
Access token privileges
Access tokens have different privileges depending on the method used to obtain them:
-
Tokens from API key authentication and App authentication have their privileges managed by the developer credentials used to obtain them.
-
Tokens from user authentication have their privileges determined by the ArcGIS account of the signed-in user.
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.
https://<LOCATION_SERVICE_URL>?token=<YOUR_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.
curl https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/arcgis/outdoor? \
-d "token=<YOUR_ACCESS_TOKEN>"
Perform geocoding
This example performs a forward geocode by making 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>"
Access a feature service
This example retrieves features from a feature service.
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=<YOUR_ACCESS_TOKEN>"
Get item details
This example accesses a private item hosted in ArcGIS.com and retrieves its properties.
curl https://www.arcgis.com/sharing/rest/content/items/<ITEM_ID> \
-d 'f=pjson' \
-d 'token=<YOUR_ACCESS_TOKEN>'