gpt4 book ai didi

python - 调用 Github.get_organization() 时出现 PyGithub BadCredentialsException

转载 作者:太空宇宙 更新时间:2023-11-04 06:00:44 24 4
gpt4 key购买 nike

我正在使用 PyGithub v1.25创建一个小 webapp,我组织的成员可以在我们的 github 组织中创建私有(private)存储库。现在,我在尝试调用 Github base classget_organization() 方法时遇到了 BadCredentialsException .

这是我的代码的相关部分:

from github import Github                                                                

import settings


GIT_OBJECT = Github(login_or_token=settings.AUTH_TOKEN)
ORG_OBJECT = GIT_OBJECT.get_organization('My-Organization-Name')

我使用的身份验证 token 是从我的 github 用户帐户生成的,在使用 github 网络界面时,该帐户具有足够的权限在该组织中创建私有(private)存储库。我用 "user", "repo", and "admin:org" scopes 创建了 token 选择。我在创建 ORG_OBJECT 时遇到错误。

堆栈跟踪:

File "/local/path/to/my/code/github_console/console/org_manage.py", line 10, in <module>
ORG_OBJECT = GIT_OBJECT.get_organization(‘My-Organization-Name’)
File "/local/path/to/my/code/github_console/lib/github/MainClass.py", line 187, in get_organization
"/orgs/" + login
File "/local/path/to/my/code/github_console/lib/github/Requester.py", line 169, in requestJsonAndCheck
return self.__check(*self.requestJson(verb, url, parameters, headers, input, cnx))
File "/local/path/to/my/code/github_console/lib/github/Requester.py", line 177, in __check
raise self.__createException(status, responseHeaders, output)
BadCredentialsException: 401 {u'documentation_url': u'https://developer.github.com/v3', u'message': u'Bad credentials'}

如果以前使用过 PyGithub 或 github API 的任何人(或比我更擅长阅读文档的人)有任何见解,我感谢您的帮助!

这是 the PyGithub source code ,以防有人想看。

最佳答案

呸!

显然,上面显示的代码效果很好,我只是将本地设置导入我的设置模块,所以使用了一个虚拟的 AUTH_TOKEN,当然,结果是 BadCredentialsException.

从好的方面来说,我想上面是正确使用 PyGithub 的演示。

关于python - 调用 Github.get_organization() 时出现 PyGithub BadCredentialsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25196774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com