【发布时间】:2019-03-07 13:22:48
【问题描述】:
我试图通过 vue js 中的 github api 向 github 进行身份验证,但它返回 401 未经授权的错误,任何想法
sendDetails(e){
e.preventDefault();
let that=this;
var b=that.username+':'+that.password;
var encodedAuth=b.toString('base64');
console.log(encodedAuth);
that.$http.post('https://api.github.com/user',{
headers: {
'Authorization' : encodedAuth
}
})
.then(function(response){
console.log(response);
});
}
但使用 curl 可以实现相同的格式
【问题讨论】:
-
基本身份验证还会在凭据前面加上
Basicdeveloper.mozilla.org/en-US/docs/Web/HTTP/Headers/… 或许这样可以解决问题。
标签: javascript vue.js github-api vue-resource