-
应该是从三月份就不能用了,使用的时候github给发了邮件提醒:
On March 25th, 2020 at 03:17 (UTC) your application (xxxxxxxxxx) used an access token (with the User-Agent okhttp/3.14.1) as part of a query parameter to access an endpoint through the GitHub API:
https://api.github.com/user
Please use the Authorization HTTP header instead as using theaccess_token
query parameter is deprecated.
Depending on your API usage, we’ll be sending you this email reminder on a monthly basis.
Visit https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param for more information about suggested workarounds and removal dates.
Thanks,
The GitHub Team -
点进去发现必须要用这种格式:
curl -H 'Authorization: token my_access_token' https://api.github.com/user/repos
自己用的是okHttp怎么解决呢
解决办法:
-
curl -H 表示添加http请求的头部,只需要在okhttp的get请求添加头部header()
如下:Request request = new Request.Builder() .url("https://api.github.com/user") .header("Authorization","token "+accessToken) .build();
自己比较菜,因为这个问题浪费好多时间,不过也算是有所收获吧,如果这篇博客帮助到其他同学记得点个赞。