I have issue with Salesforce Rest API. I've created developer account and created service application which called Salesforce through Rest API and it worked, but as I changed to production Salesforce site, the calling started failing with error code 400 for a bad request. Do you know why could it be ? all the data I am passing should be right.
var authClient = new HttpClient();
HttpContent content = new FormUrlEncodedContent(
new Dictionary<string, string>{
{"grant_type","password"},
{"client_id",ConsumerKey)},
{"client_secret",ConsumerSecret},
{"username",Username},
{"password", Password+SecurityToken}
});
JObject obj = null;
HttpResponseMessage message = authClient.PostAsync(
"https://login.salesforce.com/services/oauth2/token",
content).Result;
Error from request:
"error_description": "authentication failure",
"error": "invalid_grant"
And if I call from server directly (I added its IP as exception):
{"error_description":"grant type not supported","error":"unsupported_grant_type"}
Edit: It is most likely problem with IP restrictions, how could I manage bypass it without removing these restrictions completely?
2nd Edit It seems it was only half of the problem, as new environment is sandboxed authentication url must be different. How to know that url, and does connection depend on connected app callback url setting? If so how to set it properly?