I am building an integration from my platform whereby you can export data to your Salesforce instance, having authenticated via OAuth 2.0.
I'm experiencing the below when attempting to get an access token in the OAuth 2.0 process:
{
"error": "invalid_grant",
"error_description": "authentication failure"
}
This is the endpoint and structure I'm using, the client_id and client_secret are both set in the body:
https://test.salesforce.com/services/oauth2/token?grant_type=authorization_code&code=somerandomcode&redirect_uri=https://my-callback-url.com
This is not occurring in my local development environment. Only in a production environment. And only when attempting to authenticate into a Salesforce Sandbox environment.
Have I missed something here - do I need to create a connected app in the setup of every Salesforce instance? Or can any users just authenticate through and reuse the same connected application?
i.e if I have a Sandbox with an instanceUrl of https://cs1.salesforce.com
, which I'd like to export data to, and I have a connected app hosted at https://um3.salesforce.com
, will this cause the above error?
Could this be something to do with secure cookies where https are enforced in production but not locally? I'm at a lost here.
Any help is much appreciated.