VBlog icon indicating copy to clipboard operation
VBlog copied to clipboard

github取消通过access_token授权方式,使用Authorization授权,导致绑定Token,发布Blog等无法使用,不知道为啥作者没有维护。

Open chengfu05 opened this issue 2 years ago • 1 comments

github修改了授权的方式,取消通过access_token授权,详情查看:https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/

现在github建议:

废弃 curl "https://api.github.com/user/repos?access_token=my_access_token"

改为 curl -H 'Authorization: token my_access_token' https://api.github.com/user

需要修改的内容:/src/utils/request.js文件。

service.interceptors.request.use( config => { let token = store.state.token.token if (token) { let sp = "?" if (config.url.indexOf("?") >= 0) { sp = "&" } // 取消直接通过access_token的校验方式 // config.url = config.url + sp + "access_token=" + token // 使用Authorization的授权 config.headers = { 'Authorization': 'token ' + token } } return config })

chengfu05 avatar Dec 08 '22 06:12 chengfu05

在接口里改改,将原来的access_token改成在请求的header里加上:

Authorization: Bearer **********************************

Bearer空格后边为登录接口返回的Token。

kisekiremi avatar Jan 12 '24 09:01 kisekiremi