我正在构建一个应用程序,获取超过1K的github repos的问题和撤回请求,如下所示。
$ curl -i "https://api.github.com/repos/user/repo/issues?state=closed"我的问题是,在最初的60次迭代之后,我得到了一个速率限制错误:
{
"message": "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
"documentation_url": "https://developer.github.com/v3/#rate-limiting"
}文档说,我可以使用身份验证发出多达5000个请求,我注册了oauth,并获得了Client ID和Client Secret令牌。
https://api.github.com/repos/{repo.name}/issues?client_id=...&client_secret=...
尽管如此,只有在大约60次请求之后才会出现利率限制。
发布于 2015-11-12 09:25:00
公共GitHub API请求仅限于60 /小时/ ip,正如您所观察到的。这就是为什么你需要认证。
当您使用多种身份验证方法 API时,会出现GitHub。
基本上,您提供用户名和密码。
curl -u your-username "https://api.github.com/repos/user/repo/issues?state=closed"这将提示您输入密码。
如果您不想使用密码,可以使用个人令牌
curl -u username:token "https://api.github.com/repos/user/repo/issues?state=closed"使用个人访问令牌
这是我的最爱,但请确保您不与其他人共享令牌代码。要生成一个新的令牌,打开这个页面,您将创建令牌。
然后你可以像这样使用它:
curl "https://api.github.com/repos/user/repo/issues?state=closed&access_token=token"(用令牌代码替换url末尾的token代码段)
OAuth
如果要为其他用户实现身份验证,则应使用OAuth。文档在这个方向上是好的。
https://stackoverflow.com/questions/33655700
复制相似问题