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
Puneet SardanaPuneet Sardana 

Problem while Authorizing using REST Client

Hi,

 

I am trying to obtain access token through REST client plugin of Chrome using the following request for development purposes. I am using the following request.

 

 

https://cs13.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=CONSUMER_KEY" -d "client_secret=CONSUMER_SECRET" -d "LOGINID" -d "password=PASSWORDWITHSECURITYKEY"

 

where I am filing CONSUMER_KEY,CONSUMER_SECRET, LOGINID and PASSWORDWITHSECURITYKEY.

 

But I am getting the following response.

 

  1. Status Code: 404 Not Found
  2. Content-Type: text/html;charset=UTF-8
  3. Date: Mon, 15 Jul 2013 10:24:21 GMT
  4. Transfer-Encoding: chunked

I do not know where I am going wrong. Can somebody please help.

Best Answer chosen by Admin (Salesforce Developers) 
Vinita_SFDCVinita_SFDC

Hello Puneet,

 

For sandbox please try with test.salesforce.com and yes you need to encode as follows:

 

https://test.salesforce.com/services/oauth2/token?grant_type=password&client_id=CONSUMER_KEY&client_secret=CONSUMER_SECRET&username=USERNAME&password=PASSWORD

 

in your code:

 

body.Append("client_id=" + HttpUtility.UrlEncode(sf_clientID) + "&");
body.Append("client_secret=" + HttpUtility.UrlEncode(sf_clientSecret) + "&");
body.Append("username=" + HttpUtility.UrlEncode(sf_usernname) + "&");
body.Append("password=" + HttpUtility.UrlEncode(sf_pwd));

All Answers

Vinita_SFDCVinita_SFDC

Hello Puneet,

 

Try replacing "cs13.salesforce.com" with "login.salesforce.com" in the request. For details please refer following link:

 

http://www.salesforce.com/us/developer/docs/api_rest/Content/quickstart_oauth.htm

Puneet SardanaPuneet Sardana

Hi,

 

I am testing this on Sandbox not on production and my instance is cs13.salesforce.com.

 

Thanks,

Puneet

Puneet SardanaPuneet Sardana

While trying in production with the following url :-

 

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=CONSUMER_KEY&client_secret=CONSUMER_SECRET&username=USERNAME&password=PASSWORD

 

 

Using this I am getting following error :-

 

error: "invalid_grant"
error_description: "authentication failure - Invalid Password"
 
 

My username and password has special characters like @ and #. Do I need to encode them? Can somebody help me...

Vinita_SFDCVinita_SFDC

Hello Puneet,

 

For sandbox please try with test.salesforce.com and yes you need to encode as follows:

 

https://test.salesforce.com/services/oauth2/token?grant_type=password&client_id=CONSUMER_KEY&client_secret=CONSUMER_SECRET&username=USERNAME&password=PASSWORD

 

in your code:

 

body.Append("client_id=" + HttpUtility.UrlEncode(sf_clientID) + "&");
body.Append("client_secret=" + HttpUtility.UrlEncode(sf_clientSecret) + "&");
body.Append("username=" + HttpUtility.UrlEncode(sf_usernname) + "&");
body.Append("password=" + HttpUtility.UrlEncode(sf_pwd));

This was selected as the best answer
Puneet SardanaPuneet Sardana

I got it myself. We need to encode special symbols like @ and # in our username and password.