【问题标题】:send authenticated request while calling github api to have greater limit在调用 github api 时发送经过身份验证的请求以获得更大的限制
【发布时间】:2018-02-19 00:56:42
【问题描述】:

我从我的 python 脚本调用 github api。如果成功运行,它将进行大约 3000 次调用。但是,在成功调用 50-60 次后,它会显示以下消息 -

{'message': "API rate limit exceeded for 108.169.151.47. (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'}

我已阅读文档。我没有任何要注册的应用程序来获取客户端 ID 和客户端密码。 从我的 github 帐户中,我生成了一个令牌。我想知道是否可以使用它来发送经过身份验证的请求。 我尝试了一些 curl 命令通过 git bash 中的 github 配置文件登录,然后运行 ​​python 脚本,但它仍然显示相同的消息。

您能建议我如何利用消息中的好消息吗?

【问题讨论】:

    标签: python curl github-api


    【解决方案1】:

    您可能需要考虑仅对 GitHub username 和 password 使用基本身份验证。收到的响应应转换为 JSON。

    req = requests.get(url, auth=(USERNAME, PASSWORD))
    req_json = req.json()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-22
      • 2019-03-29
      • 2016-05-01
      • 2016-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多