【发布时间】:2019-05-08 07:59:03
【问题描述】:
我想使用 GitHub API 创建一个要点。我尝试了一个 POST ajax 请求:
var gist = {
"description": "Avatars",
"public": true,
"files": {
"check.txt": {
"content": "Avatars list..."
}
}
};
$.ajax({
url: 'https://api.github.com/gists',
type: 'POST',
dataType: 'json',
data: JSON.stringify(gist),
success: function(e) {
console.log(e);
},
error: function(e) {
console.error("Error!: ", e);
}
});
但我总是收到以下错误:
jquery-3.1.1.min.js:4 POST https://api.github.com/gists 401 (Unauthorized)
谁能帮帮我? 谢谢
【问题讨论】:
-
您需要在拨打电话时提供凭据,以显示您的身份并证明您有访问权限。请参阅链接的“身份验证”部分:developer.github.com/v3/gists/#authentication
标签: javascript jquery github gist