reactjs - 当我尝试登录时,GitHub API 返回消息需要身份验证
问题描述
const fetchUser = async () =>{
let username : any = (document.getElementById('username') as HTMLInputElement).value;
let password : any = (document.getElementById('password') as HTMLInputElement).value;
const profile = await fetch("https://api.github.com/user", {
headers:{
'Authorization': 'Basic ' + window.btoa(username + ":" + password)
}
})
const profileResponse = await profile.json()
console.log(profileResponse)
}
const handleSubmit =(e:any) =>{
e.preventDefault()
fetchUser()
}
我尝试使用 GitHub API 使用 GitHub 凭据登录,但它返回所需的身份验证
解决方案
Github.com 已停止使用username
和对 API 进行密码验证password
。
推荐阅读
- flutter - Firebase 身份验证!即使我输入非注册用户,我也可以移动到主页
- css - 是否有另一种方法可以使列布局更好地响应?
- java - HTTP GET REQUEST (HTTPURLCONNECTION) set-cookie null (NOT HTTPONLY COOKIE)
- javascript - 如何将数组中的数组拆分为json?地图 Javascript
- laravel - 改变字体粗细也改变 font-family Laravel--dompdf
- makefile - 当通配符是字符串的一部分时,Makefile 中的通配符目标
- java - Itext 7 PDF - 将图像添加到文档不会刷新到磁盘,但会保留在内存中,这与 Itext 5 不同
- laravel - Illuminate\Contracts\Container\BindingResolutionException .Target 类 [MarketsouhaibController] 不存在。拉拉维尔 8
- flutter - 被 18 像素抖动溢出
- javascript - 选中复选框时显示按钮