我正在尝试使用我的跑道应用程序的应用程序身份验证获取访问 token 。
目前,我的代码如下所示:
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);
我不断收到 400 错误,这意味着请求错误。但我已经使用 Beeceptor 对其进行了测试,它工作正常且看起来不错。 我不确定我做错了什么......
最佳答案
终于明白了。添加一行代码...
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
这完美地修复了它。 在这里找到解决方案:https://help.podio.com/hc/en-us/community/posts/207481648-Cannot-authenticate-by-app-id
关于javascript - 对跑道应用程序进行应用程序身份验证时收到 400 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56833540/