Direct username password authentication

There are situations when it is not possible to use OAuth 2.0 processes to obtain an access token; this is most common when developing command line applications, scripting with ArcGIS REST JS and the ArcGIS API for Python, or when using the ArcGIS REST APIs.

Using the generateToken REST API endpoint, you can get an access token by sending the username and password directly.

Get an access token

  1. POST a generateToken request with the username, password, and referer.
  2. The response contains the access token.
RequestResponse
      
1
2
3
4
5
6
curl https://www.arcgis.com/sharing/rest/generateToken \
 -X POST \
 -d 'f=pjson' \
 -d 'username=USERNAME' \
 -d 'password=PASSWORD' \
 -d 'referer=https://YOUR-APP.com'
     
1
2
3
4
5
{
  "token": "iX_oSlAphdxzi...",
  "expires": 1609488000000,
  "ssl": true
}
cURLArcGIS REST JSArcGIS API for Python
      
1
2
3
4
5
6
curl https://www.arcgis.com/sharing/rest/generateToken \
 -X POST \
 -d 'f=pjson' \
 -d 'username=USERNAME' \
 -d 'password=PASSWORD' \
 -d 'referer=https://YOUR-APP.com'

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