I had built and started running an integration, which was working fine for a while... Then it started erroring all of a sudden with:

{ "error": "invalid_grant", "error_description": "authentication failure" }

The request that fails is:

curl --location 'https://<company>.my.salesforce.com/services/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=<redacted>' \
--data-urlencode 'client_secret=<redacted>' \
--data-urlencode 'username=<email>' \
--data-urlencode 'password=<password><secretKey>'

And nothing was changed in SalesForce!

Its still within API Limits, but I would expect that to raise a different error.

Update: Just noticed this is the raw error I get from the Ruby gem I am using:

Caused by Restforce::UnauthorizedError: Connection prefix not set
  • Its still within API Limits, but I would expect that to raise a different error.: you sure about that? github.com/restforce/restforce/issues/367
    – identigral
    Commented May 23, 2023 at 14:23
  • Yeah... I have also just found that post, and am writing up a answer to detail how I got it working... thanks! Commented May 23, 2023 at 14:28

1 Answer 1


Found several bits of info I've not seen on any other answer...

  1. Salesforce has a "login limit"!

Apparently its 3600/hr (https://github.com/restforce/restforce/issues/367#issuecomment-374814177)

Although the /limits API has no key relating to "login limits"!

As I was creating a new client on each request, so moved to Singleton.

After a while, I was able to login again without any changes, but it failed intermittently...

  1. Accounts can get locked!

worked for me: I had to "unlock" the user manually - I went to user/edit and there was an "unlock" button available. 1 click and no more errors:)



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .