3

so I've been trying to use JSForce to authenticate into SF. I used both the first example with SOAP API login and the second one with OAuth2: https://jsforce.github.io/document/#connection

However, I keep getting the same error each time:

XMLHttpRequest cannot load https://login.salesforce.com/services/oauth2/token. No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any help? The account credentials used to authorize are a system admin, so permissions shouldn't be an issue, and I have the redirect URI as redirectUri : 'https://login.salesforce.com/services/oauth2/authorize'

  • 2
    I guess that is due to same origin policy of browsers. You will require a proxy as documented. You cannot make GET/ POST calls from JavaScript to another domain. github.com/jsforce/jsforce-ajax-proxy/blob/master/README.md – manjit5190 Oct 8 '15 at 17:31
  • Are there any ways to authenticate that doesn't require this proxy? I'm using a cloud-based host service so I can't install anything like this link requires. How do people normally authenticate external apps to SF? – AKor Oct 8 '15 at 18:00
  • 1
    Setup > Security Controls > CORS will allow you to safely allow your site access using JSForce. – sfdcfox Oct 8 '15 at 18:24
  • I believe that will not work on login.salesforce.com because the request will go to an authentication server, however you may give it a try. – manjit5190 Oct 8 '15 at 18:54
  • @manjit_singh - login.salesforce.com does not enforce same origin policy (AFAIK), it only enforces no iframe which is why lightning broke it..... – Eric Oct 8 '15 at 18:57

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.