【问题标题】:PyGitHub .RateLimitExceededException: 403 Authentication TroublePyGitHub .RateLimitExceededException:403 身份验证问题
【发布时间】:2022-01-14 01:13:19
【问题描述】:

我一直在尝试使用 PyGitHub 使用 PyGitHub 编辑/更新我的存储库文件,但是(我想我尝试访问它的次数太多了:P)它给了我这个错误:

github.GithubException.RateLimitExceededException: 403 {"message": "API rate limit exceeded for xx.xx.xx.xxxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"} 

我之前可以很好地访问数据。我已经对其进行了研究,为了解决这个问题,我用访问令牌替换了我的用户名。这是我的完整代码:

from github import Github


# Github username
username = "JosephCWatkins"
password = yeoldepasswordhere
# pygithub object
g = Github(yeolaccesstokenhere, password) 
user = g.get_user(username)


repof =  g.get_repo("JosephCWatkins/moonspellprojectprogress") 


#me trying to access the data :P: 
contents = repof.get_contents("test.txt")
print(contents.content.split.__doc__()) 


它说我必须对自己进行身份验证,这会给我一个更高的速率限制,但我想解决它的最好办法是添加访问令牌。难道我做错了什么?如何验证自己以便继续使用 API?而且,如果您能帮助我打印存储库文件的内容。谢谢你。 :)

【问题讨论】:

    标签: python authentication github pygithub


    【解决方案1】:

    我的问题的第一部分仍未得到解答,但我使用以下代码访问了我的 GitHub 存储库文件的内容:

        repo =  g.get_repo("username/repositoryname") 
        contents = repo.get_contents("filename.filetype").decoded_content 
    

    我知道这听起来很简单,但文档并没有像它应该的那样介绍各种功能,它主要只是提供示例。此外,互联网缺乏对这个问题的简单答案。对于任何想通过 PyGitHub 访问他们的 GitHub 文件的人,这里就是。

    【讨论】:

      猜你喜欢
      • 2019-12-04
      • 2017-07-06
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 2013-07-23
      • 2015-08-25
      • 2010-11-17
      相关资源
      最近更新 更多