【发布时间】: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