I am connecting with the Salesforce API using OAuth, refresh_token, client_id & client_secret.

API calls are failing randomly with, it's not every API call but 1 in 100 or sometime in 1000 will fail with invalid_grant: authentication failure. Below is the example of the request I am doing to salesforce.

curl -X POST \
 https://login.salesforce.com/services/oauth2/token \
 -H 'Cache-Control: no-cache' \
 -H 'Content-Type: application/x-www-form-urlencoded' \
 -d 'grant_type=refresh_token

The solution I tried but didn't work:-

  • Creating a new refresh_token.
  • Relaxing API limit for the app.

Some more information on the issue:-

  • This bug started coming out of nowhere after we migrated our Salesforce instance to custom URL e.g:- myorg.my.salesforce.com, could there be an issue because of that?

Eventually found out we were running out of our API credits, though /auth/token isn't counted as API request but just reducing the API calls fixed it for us.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.