function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abilash Kosigi 8Abilash Kosigi 8 

Requesting OAuth Token from Curl (Rest API)


I am new to REST API. I would like to send Http Requests from Curl software that I installed on my desktop.
How to request OAuth token from command prompt using Curl.(I have done extensive search on google - could not find any reliable answer). 

What is the callback URL that I should give in Salesforce dev edition.

Please help
Since you cannot really do three legged oauth with CURL, you need to use Username-password flow to get access token,   please see below

For the callback URL you can use something like http://test or http://localhost.

Grazitti TeamGrazitti Team
Hi Abhilash,

Try using the below cURL command :

curl -k -d "grant_type=password" -d "client_id=[clientid]" -d "client_secret=[clientsecret]" -d "username=[myusername]" -d "password=[mypassword][mysecuritytoken]"

It will return you the access token.

Mark it as Best Answer, if it helps you

Grazitti Team
Abilash Kosigi 8Abilash Kosigi 8
Hi Grazitti,

I am getting the following error when I am trying cURL Command that you mentioned.

{"error":"invalid_grant","error_description":"authentication failure"}

Please help.
Grazitti TeamGrazitti Team
Just make sure you are using correct clientId, client_secret, username and password. Also, if you are doing it on sandbox your url should be
Abilash Kosigi 8Abilash Kosigi 8
Unfortunately I am still facing the same issue :(

Grazitti TeamGrazitti Team
Its working fine on our end.

Also, Just make sure that you are entering proper combination of Password and Security Token.

If you still face the same issue send us the cUrl command you are hitting as well as the error genarated.
Sanjay SubramanianSanjay Subramanian
I am facing the same issue as Abilash.
See my post here (scroll to the bottom)
Sanjay SubramanianSanjay Subramanian
Anyone with ant thoughts or ideas that could help ?