Reputation: 31
I'm trying to get an access token using app authentication for my Podio App.
Currently, my code looks like so:
const authUrl = 'https://podio.com/oauth/token';
const data= "grant_type=app&app_id="+appId+"&app_token="+appToken+"&client_id="+clientId+"&redirect_uri="+uri+"&client_secret="+clientSecret;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("requestResponse").innerHTML = this.responseText;
}
};
xhttp.open("POST",authUrl, true);
xhttp.send(data);
I keep getting a 400 error, which means the request is bad. But I've tested it using Beeceptor and it works and looks fine. I'm not sure what I'm doing wrong...
Upvotes: 0
Views: 143
Reputation: 31
Finally figured it out. Adding a line of code...
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
This fixed it perfectly. Found solution here: https://help.podio.com/hc/en-us/community/posts/207481648-Cannot-authenticate-by-app-id
Upvotes: 3