There are situations when it is not possible to use a secure OAuth 2.0 flow to obtain an access token. This is most common when developing command line applications, scripting with the ArcGIS API for Python, or when using the ArcGIS REST APIs. The generate
operation allows you to get an access token using your username and password. This flow adheres to the resource owner password credentials grant type defined in the OAuth 2.0 specification.
Get an access token
To get an access token, use the generate
operation and set a username
, password
, and referer
. The generate
operation only supports POST
requests.
curl https://www.arcgis.com/sharing/rest/generateToken \
-d 'f=json' \
-d 'username=USERNAME' \
-d 'password=PASSWORD' \
-d 'referer=https://www.arcgis.com' \
-d 'client=referer'