8

I'm using Salesforce developer account and trying to obtain OAuth access token using curl and it returns 500 Server Error giving the message specified in [1].

Used curl command is curl -v -H "Content-Type: application/x-www-form-urlencoded" -H "X-PrettyPrint:1" -d "grant_type=password&client_id=<C_ID>&client_secret=<SECRET>&username=<UN>&password=<PW>" https://login.salesforce.com/services/oauth2/token

What i conclude is, this happens because of mis-configuring Callback URL of OAuth app configurations. I cannot understand what would be intended value for that because i dont have any URL to redirect.

I have tried configuring https://login.salesforce.com/services/oauth2/success as the Callback URL value and had no luck.

What would be the use of Callback URL setting to https://login.salesforce.com/services/oauth2/success or what is the correct way of getting access token using curl?

Thanks in advance.

[1]

<html>
<head><title>An internal server error has occurred</title></head>
<body>


<div style="display:none;" id="errorTitle">An internal server error has occurred</div>
<div style="display:none;" id="errorDesc">An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact <a href="https://help.salesforce.com/apex/hthome">Salesforce Support</a>. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. <br/><br/>Thank you again for your patience and assistance. And thanks for using salesforce.com!</div>
<table cellspacing=10>
<tr><td><span style="font-weight: bold; font-size: 12pt;">An internal server error has occurred</span></td></tr>
<tr><td>
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact <a href="https://help.salesforce.com/apex/hthome">Salesforce Support</a>. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. <br/><br/>Thank you again for your patience and assistance. And thanks for using salesforce.com!
<br><br>
Error ID: <NUMBER> (<NUMBER>)
</td>
</tr>
<tr><td>
<br clear="all"><br><br>


</td></tr>
</table>

</td></tr>
</table>



</body>
</html>
7

First you need to create a remote Application .

Setup -->Create --> App-->Connected Apps-->Fill The Necessary Details --> mention CallBackURL as https://ap1.salesforce.com/services/oauth2/token ,Callback URL in salesforce is nothing but what Salesforce will callback with once the user authorizes access to his/her Salesforce account. Provide callback url as https://ap1.salesforce.com/services/oauth2/token

After Saving the Application you'll have the customerid and CustomerKey .

curl --form client_id=your customer key --form client_secret=your sceret key --form grant_type=password --form username=123@force.com --form password=your password+Security -k https://ap1.salesforce.com/services/oauth2/token

After Executing This Command

PS : If you have trouble to find security token, refer http://boards.developerforce.com/t5/APIs-and-Integration/Having-trouble-getting-Access-Token-with-username-password/td-p/278305

  • Thanks Vineeth this helped me to get access token. I have used the curl command mentioned in the question to get access token from a another domain. So that the command is valid, but i don't have permission to view configuration of the application to lookup how did it configured. Wonder how does that worked. And i would like to know is there any valid use case for using login.salesforce.com/services/oauth2/success as the callback uri which is asked as the title? Thanks a lot – DarRay Nov 12 '13 at 13:15
  • 1
    @DarRay - login.salesforce.com/services/oauth2/success is used with the user-agent profile for mobile apps. The app displays a WebView for the OAuth login URL, and registers a handler for the URL change event. When the URL changes to login.salesforce.com/services/oauth2/success, the handler knows the OAuth process is complete and can read the token etc from the hash fragment. See wiki.developerforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com for much more. – metadaddy Nov 12 '13 at 19:26
  • Got the idea. Thanks Vineeth for the clarification. – DarRay Nov 13 '13 at 4:48

protected by Eric Nov 4 '16 at 18:14

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.