I have developed a client application that accesses Salesforce REST API through OAuth 2 using the Go programming language. Everything works fine locally: I have a correct token, client ID, client secret, and service account. On Salesforce side, I have set up OAuth application privilege, and I am getting data from Salesforce REST API.

So I am moving my application and hosting it on AWS Elastic beanstalk. The configuration on AWS EB is exactly the same as my local development environment, except that there is a Nginx reverse proxy between my Go service on EB and Salesforce. On my local computer, all requests to Salesforce were directly sent from the Go service without any reverse proxy.

On AWS, things were broken: I have been getting "error":"invalid_grant","error_description":"user hasn't approved this consumer" with an HTTP 400 from Salesforce, thus I cannot get any data as I did locally. However, on Salesforce side, the authentication log in the service account shows the authentication was sucessful. I also made sure that the call back URL was set to be my EB instance URL.

I have done researches on the Internet but none of the previous posts on StackExchange was helpful to the problem I am in. Could Nginx be the problem in this case, or did I miss something else for production?

[Edit] More detailed technical info: The request that my service is sending to Salesforce is:

POST https://login.salesforce.com/services/oauth2/token
Content-Type: application/x-www-form-urlencoded
Body (form-data):
grant_type: urn:ietf:params:oauth:grant-type:jwt-bearer
assertion: <my token here>

On Postman, the response that I got is:

    "access_token": "access token here",
    "scope": "api",
    "instance_url": "https://myinstance.my.salesforce.com",
    "id": "https://login.salesforce.com/id/someid/anotherid",
    "token_type": "Bearer"

My Go client receives the same locally, but receives the invalid_grant on AWS.

Your Answer

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

Browse other questions tagged or ask your own question.