github.GithubException.GithubException:401 {'message':'需要认证',

时间:2019-05-07 21:36:10

标签: python github github-api

我需要使用client_id和client_app通过python通过Github API进行身份验证,以便可以利用github应用程序在github企业上发布消息。

代码:

from github import Github

client_id=<xyz>
client_secret=<abc>
g = Github(base_url="https://<enterprise>/api/v3", client_id=client_id, client_secret=client_secret)

for repo in g.get_user().get_repos():
    print(repo.name)

repo = g.get_repo("<repo>")
repo.create_issue(title="This is a new issue", body="This is the issue body")

错误:

  

Traceback (most recent call last): File "script.py", line 7, in <module> for repo in g.get_user().get_repos(): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/PaginatedList.py", line 64, in __iter__ newElements = self._grow() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/PaginatedList.py", line 76, in _grow newElements = self._fetchNextPage() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/PaginatedList.py", line 201, in _fetchNextPage headers=self.__headers File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/Requester.py", line 275, in requestJsonAndCheck return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url))) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/github/Requester.py", line 286, in __check raise self.__createException(status, responseHeaders, output) github.GithubException.GithubException: 401 {'message': 'Requires authentication', 'documentation_url': 'https://developer.github.com/enterprise/2.16/v3/repos/#list-your-repositories'}

我无法使用Github应用程序client_id和client_secret吗?

0 个答案:

没有答案