Generate a token

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 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.

When using this authentication method, the following best practices are recommended:

  • Use HTTPS for all requests.
  • Do not store or log user credentials anywhere in your application or script.
  • Consider using a secure configuration for application secrets.
  • Require users to enter their credentials into your application or script.

Get an access token

To get an access token, use the generateToken operation and set a username, password, and referer.

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.