You need to sign in to do that
Don't have an account?

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.
- Status Code: 404 Not Found
- Content-Type: text/html;charset=UTF-8
- Date: Mon, 15 Jul 2013 10:24:21 GMT
- Transfer-Encoding: chunked
I do not know where I am going wrong. Can somebody please help.
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
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
Hi,
I am testing this on Sandbox not on production and my instance is cs13.salesforce.com.
Thanks,
Puneet
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 :-
My username and password has special characters like @ and #. Do I need to encode them? Can somebody help me...
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));
I got it myself. We need to encode special symbols like @ and # in our username and password.