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
Angie WinterbottomAngie Winterbottom 

Please help with OAUTH2 tokens

I am trying to get Auth to work for a webservice on a website which needs to read / update Salesforce data without the need for a website user to log into Salesforce.

I'm trying to use the token model for OAUTH2 as suggested in http://www.mstsolutions.com/blog/content/testing-salesforce-web-service-using-postman-rest-client - I have set up a connected app and created a new username and password specifically for it, in my Salesforce playground.

Here's the raw data that gets posted to Salesforce (captured using Fiddler). I tried to post the simplest thing I could. Please can you tell me whether there's anything you see that's obviously wrong:

========================================

POST https://login.salesforce.com/services/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: login.salesforce.com
Content-Length: 216
Expect: 100-continue
Connection: Keep-Alive

grant_type=password&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&username=<USERNAME@PLAYGROUND>&password=<PASSWORD>

========================================

The response I get is a 500 internal server error.

"Error ID: 1820186503-109722 (215530434)"

I went to https://help.salesforce.com/apex/hthome to try and raise a support ticket, but when I try to log in, after it appears to succeed, it redirects me to https://help.salesforce.com/apex/Help_Home?err=1 and kicks me out (not logged in).

If I try the same thing with charset set to UTF-8 in the headers, I get a 400 Bad Request reponse:

"You have sent us an Illegal URL or an improperly formatted request."

I don't know what to try next, I am not getting much out info of this Auth API at all. All suggestions welcome!