I can't get access token via AJAX request


#1

CORS problem, but I used a proxy server - error code 429

$.ajax({
type: “POST”,
url: “https://thingproxy.freeboard.io/fetch/https://graph.api.smartthings.com/oauth/token?grant_type=authorization_code&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&code=” + currentSettings.authorization_code + “&scope=app&redirect_uri=www.freeboard.io”,
data: {
grant_type: “authorization_code”,
code: currentSettings.authorization_code,
client_id: “”,
client_secret: “”,
redirect_uri: “www.freeboard.io”
},
headers: {
“Content-Type”: “application/x-www-form-urlencoded”
},
success: function (payload) {
console.log(payload);
currentSettings.access_token = payload.access_token;
getData();
},
beforeSend: function (xhr) {
xhr.setRequestHeader (“Authorization”, "Basic " + btoa(“CLIENT_ID:CLIENT_SECRET”));
},
});

I omitted client id and client secret,

Please help.