HOW TO

Generate an ArcGIS Online OAuth 2.0 token using cURL in CMD

Last Published: April 14, 2025

Summary

cURL is a free and open-source computer software project providing a library and command-line tool for transferring data using various network protocols. The name stands for "Client for URL".

OAuth 2.0 is an authorization protocol and NOT an authentication protocol. In this article we look at a workflow to generate ArcGIS Online OAuth 2.0 token using cURL with the help of a registered application within ArcGIS Online using its client_id and its client_secret. You can use OAuth 2.0 to authenticate ArcGIS users to access content and location services on behalf of the authenticated user.

Procedure

  1. Create a new app in ArcGIS Online, following the instructions in: Add and register an app, and choosing Other application as the app type.
  2. Download curl for Windows. At the command prompt (CMD), navigate to the curl.exe path, and run the below cURL command:

Example:

curl -X POST -d client_id=ZbJ1dzdXc2cYHYPF -d client_secret=e9bce20fce0b4a078b54877bfab03533 -d grant_type=client_credentials https://www.arcgis.com/sharing/oauth2/token
Note:
Replace the client_id and the client_secret with the information from your registered 'Other application'.

example of running the tool in the command prompt window

  • Additionally, if needed you can also include the Header in the request (with -H) for cURL with verbose logging (with -v) and with the option to include the headers in the HTTP output (with -i).... similar to earlier cURL request:

Example:

curl -X POST -H 'Accept-Encoding:gzip,deflate' -d client_id=ZbJ1dzdXc2cYHYPF -d client_secret=e9bce20fce0b4a078b54877bfab03533 -d grant_type=client_credentials https://www.arcgis.com/sharing/oauth2/token -v -i

Article ID: 000034096

Software:
  • ArcGIS Online

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options