Skip to main content
added 7 characters in body; edited tags
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

Following the stackappsStack Apps documentation Authentication (explicit) section I crafted this ajaxAJAX call

        $.ajax({
            url:"https://stackexchange.com/oauth/access_token",
            type:"POST",
            data: {
                client_id: myClientID,
                client_secret: myClientSecret,
                code: getUrlParameter("code"),
                redirect_uri: "https://myapp.com/sameAsBefore" 
            },
            success: function(data){
                console.log(data);
            }
        });
    

However, this is not accepted.

XMLHttpRequest cannot load https://stackexchange.com/oauth/access_token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://myapp.com' is therefore not allowed access.

I tried removing the contentTypecontentType and dataTypedataType as they will default to application/x-www-form-urlencodedapplication/x-www-form-urlencoded and a best guess for the returning data. No change if they are there or not.

Any ideas what I am missing?

Following the stackapps documentation Authentication (explicit) section I crafted this ajax call

        $.ajax({
            url:"https://stackexchange.com/oauth/access_token",
            type:"POST",
            data: {
                client_id: myClientID,
                client_secret: myClientSecret,
                code: getUrlParameter("code"),
                redirect_uri: "https://myapp.com/sameAsBefore" 
            },
            success: function(data){
                console.log(data);
            }
        });
    

However, this is not accepted.

XMLHttpRequest cannot load https://stackexchange.com/oauth/access_token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://myapp.com' is therefore not allowed access.

I tried removing the contentType and dataType as they will default to application/x-www-form-urlencoded and a best guess for the returning data. No change if they are there or not.

Any ideas what I am missing?

Following the Stack Apps documentation Authentication (explicit) section I crafted this AJAX call

        $.ajax({
            url:"https://stackexchange.com/oauth/access_token",
            type:"POST",
            data: {
                client_id: myClientID,
                client_secret: myClientSecret,
                code: getUrlParameter("code"),
                redirect_uri: "https://myapp.com/sameAsBefore" 
            },
            success: function(data){
                console.log(data);
            }
        });
    

However, this is not accepted.

XMLHttpRequest cannot load https://stackexchange.com/oauth/access_token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://myapp.com' is therefore not allowed access.

I tried removing the contentType and dataType as they will default to application/x-www-form-urlencoded and a best guess for the returning data. No change if they are there or not.

Any ideas what I am missing?

Source Link

No 'Access-Control-Allow-Origin' for oauth/access_token

Following the stackapps documentation Authentication (explicit) section I crafted this ajax call

        $.ajax({
            url:"https://stackexchange.com/oauth/access_token",
            type:"POST",
            data: {
                client_id: myClientID,
                client_secret: myClientSecret,
                code: getUrlParameter("code"),
                redirect_uri: "https://myapp.com/sameAsBefore" 
            },
            success: function(data){
                console.log(data);
            }
        });
    

However, this is not accepted.

XMLHttpRequest cannot load https://stackexchange.com/oauth/access_token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://myapp.com' is therefore not allowed access.

I tried removing the contentType and dataType as they will default to application/x-www-form-urlencoded and a best guess for the returning data. No change if they are there or not.

Any ideas what I am missing?