I was trying to call OAuth from our website but it gives an error

Access to XMLHttpRequest at 'https://.salesforce.com/services/oauth2/token' from origin 'https://***.com.ph' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

And i already added this on COR Policy enter image description here

here is the Javascript im Using

         beforeSend: function(xhr) {
        xhr.setRequestHeader("Access-Control-Allow-Origin", "*");
    contentType: 'application/json',
    cache: false,
        type: "POST",
        url: "https://***.salesforce.com/services/oauth2/token",
        data: {
        success: function (response) {
            //service.php response
            // jQuery("#form-field-uthentication_token").val(response.access_token);
  • Hi, did you resolve it ? I am facing the same issue! Commented Jun 11, 2022 at 9:21

1 Answer 1


I would suggest you to add your site into below:

  1. CSP Trusted Sites
  2. CORS Setting

In addition to the above, did you try using ConnectedApp to achieve what you wanted?

Also i had used Allow CORS: Access-Control-Allow-Origin chrome extension to test.

Let me know if it helps.

  • I did try.. still the same.... :( Commented Jun 25, 2021 at 8:21

You must log in to answer this question.

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