如何解决XMLHttpRequest 请求 Github 访问令牌不起作用
var requestAccessToken = function(){ var data = "client_id=client_id&client_secret=client_secret&grant_type=client_credentials";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange",function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST","https://github.com/login/oauth/access_token");
xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
// xhr.setRequestHeader("Cookie","JSESSIONID=23263F8AD7E79CABCA184EBB2CA95BE3");
xhr.onload = function () {
// Parse API data into JSON
const Accesstoken = JSON.parse(this.response);
}
console.log('tokennn')
xhr.send(data);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。