我正在尝试使用我的 github 应用程序执行 oauth,然后读取经过身份验证的用户存储库和组织。 但是,对于与“列出用户的安装”、“列出可供用户安装以进行安装的存储库”和许多其他端点相关的查询,我无法获得相同的 pygithub api。
参考链接:http: //pygithub.readthedocs.io/en/latest/apis.html
PS。 以前我使用 oauth 应用程序并且能够执行流程,现在因为我还需要监听我需要订阅 webhook 的事件,所以我切换到 github 应用程序。
想为此工作。
这个功能会很有帮助:+1:
这在 #1021 中有介绍,但正在等待批准/合并, @sfdye我们可以关注它吗?
获取 auth_token:
`
installations_url = " https://github.com/api/v3/app/installations "
installations_response = requests.get(installations_url, headers=headers, auth=CustomJWTAuth())
installations_response.raise_for_status()
for item in installations_response.json():
installation_id = item['id']
#print (installation_id)
access_tokens_url = "https://github.com/api/v3/app/installations/{installation_id}/access_tokens".format(
installation_id=installation_id)
access_tokens_response = requests.post(access_tokens_url, headers=headers, auth=CustomJWTAuth())
access_tokens_response.raise_for_status()
#print (access_tokens_response.json())
token = access_tokens_response.json()['token']
#print (token)
#return github3.login(token=token)
return token
raise Exception("No app installations")
`
查看https://pypi.org/project/github-bot-api/ ,它使用为您提供 GitHub 应用程序及其安装的 PyGithub 客户端。 (免责声明:我是那个包的作者)
最有用的评论
想为此工作。