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
MagneticDiskMagneticDisk 

OAuth 2.0 Password flow, "unknown_error"

When requesting an access token from https://login.salesforce.com/services/oauth2/token, I get the response:

 

unknown error, please retry your request

 

I seem to be making a well-formatted request with proper credentials, but I get this mysterious error.  Has anybody seen this and can anybody help?

 

Many thanks,

MagneticDisk

statforcestatforce

I am facing the very same issue.

@MagneticDisk : were you able to figureout what the issue is about? 

MagneticDiskMagneticDisk

I have not figured this out.  Here is my HTTP Request, does it match yours?  Do I need to pass something else in the header?  User-agent?  Accepts?

 

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

 


grant_type=password&client_id=[foo]&client_secret=[bar]&username=[baz]&password=[woof]

statforcestatforce

Are you using the security token along with the password?

 

I get  

{"error":"unknown_error","error_description":"retry your request"}

message. This happens only for the developer account. I tried the same authentication method on a professional (trial) and a group edition with success.

 

 Below is the command i use. I made sure i am using the correct client_id/client_secret/password+securityToken

 

curl https://login.salesforce.com//services/oauth2/token -d "grant_type=password&client_id={client_id}&client_secret={secret}&username={uname@email.com}&password={password+SecurityToken}"

MagneticDiskMagneticDisk

Yes, I'm using password + security token.  I am wondering, like you, if it isn't something specific to the dev env that's the problem.

rich pedersenrich pedersen

I had same problem with my salesforce account yesterday.  I then created a new test org and it worked this morning and when I came back this afternoon I was back to this message with no changes to my code.

 

HTTP/1.1 400 Bad Request
Server:
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 05 Nov 2012 21:50:52 GMT

0042
{"error":"unknown_error","error_description":"retry your request"}

 

Any help would be much much appreciated.

edanpedanp

I had the same issue on developer account. Solved it eventually when I submitted the request to https://ap1.salesforce.com instead of https://login.salesforce.com

 

ap1.salesforce.com is the domain I see when I login to my account from the browser.

zachelrathzachelrath

Changing from login.salesforce.com to <instanceURL>.salesforce.com solved it for me as well!

 

Does anyone know why this is??? I was beating my head against the wall for over an hour trying to figure this out.

Greg Berns 4Greg Berns 4
If you are using .NET, this solved my problem:
http://stackoverflow.com/questions/38482611/vb-net-salesforce-post-request-returns-400-bad-request-error

Add this to your code:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
SAP BizTalk IntegrationSAP BizTalk Integration
Thank you Greg Berns!!!

This was my issue. I'm developing a integration solution using BizTalk, and neither the sample article in Salesforce.com nor the one in MSDN (microsoft site) have this line of code. I wasted time thinking about issues witht the header values like Expect or Connection, even UrlEncode issues with the paramteres in the payload. But nooooo... freaking TLS setting.
Tuan VoTuan Vo
Thank Greg Berns, this line of code saves me. 
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11