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

Python 调用Github.get_organization()时出现PyGithub BadCredentialsException,python,git,github,github-api,Python,Git,Github,Github Api,我正在使用创建一个小webapp,我的组织成员可以在我们的github组织中创建私有存储库。现在,我在尝试调用的get\u organization()方法时遇到了BadCredentialsException 以下是我的代码的相关部分: 我使用的身份验证令牌是从我的github用户帐户生成的,该帐户在使用github web界面时有足够的权限在此组织中创建私有存储库。我用selected创建了令牌。我在创建ORG\u对象时出错 堆栈跟踪: File "/local/path/to/my/co

我正在使用创建一个小webapp,我的组织成员可以在我们的github组织中创建私有存储库。现在,我在尝试调用的
get\u organization()
方法时遇到了
BadCredentialsException

以下是我的代码的相关部分:

我使用的身份验证令牌是从我的github用户帐户生成的,该帐户在使用github web界面时有足够的权限在此组织中创建私有存储库。我用selected创建了令牌。我在创建
ORG\u对象时出错

堆栈跟踪:

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'}
File”/local/path/to/my/code/github\u console/console/org\u manage.py”,第10行,在
ORG\u OBJECT=GIT\u OBJECT.get\u organization('My-organization-Name'))
get_组织中的文件“/local/path/to/my/code/github_console/lib/github/MainClass.py”,第187行
“/orgs/”+登录
文件“/local/path/to/my/code/github_console/lib/github/Requester.py”,第169行,位于requestJsonAndCheck中
返回self.\u check(*self.requestJson(动词、url、参数、标题、输入、cnx))
文件“/local/path/to/my/code/github\u console/lib/github/Requester.py”,第177行,在检查中
引发自我。创建异常(状态、响应负责人、输出)
BadCredentialsException:401{u'文档\u url':u'https://developer.github.com/v3“,u'message”:u'Bad credentials'}
如果以前使用过PyGithub或github API的任何人(或者在阅读文档方面比我更好的人)有任何见解,我感谢您的帮助

这是,以防有人想看一下。

Doh

显然,上面显示的代码工作得很好,我刚刚将本地设置导入了我的设置模块,因此使用了一个虚拟的
AUTH_令牌
,当然,这导致了
BadCredentialsException


从好的方面来看,我想上面是PyGithub正确用法的一个演示。

您能在终端中用curl请求重现这个问题吗?这样做会很有帮助,因为它会告诉您这是否是库中的问题或您如何使用API的问题。好主意,我会尝试一下,然后更新我的帖子auth令牌来自哪里?是因为为我的组织注册了一个新的GitHub应用程序?
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'}