Generate token flow

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 generateToken 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 generateToken operation and set a username, password, and referer. The generateToken operation only supports POST requests.

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
5
6
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'

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