Pygithub: 支持 github 应用程序

创建于 2018-06-26  ·  5评论  ·  资料来源: PyGithub/PyGithub

我正在尝试使用我的 github 应用程序执行 oauth,然后读取经过身份验证的用户存储库和组织。 但是,对于与“列出用户的安装”、“列出可供用户安装以进行安装的存储库”和许多其他端点相关的查询,我无法获得相同的 pygithub api。

参考链接:http: //pygithub.readthedocs.io/en/latest/apis.html

PS。 以前我使用 oauth 应用程序并且能够执行流程,现在因为我还需要监听我需要订阅 webhook 的事件,所以我切换到 github 应用程序。

Hacktoberfest feature request

最有用的评论

想为此工作。

所有5条评论

想为此工作。

这个功能会很有帮助:+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 客户端。 (免责声明:我是那个包的作者)

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

nchammas picture nchammas  ·  3评论

surajjacob picture surajjacob  ·  4评论

psychemedia picture psychemedia  ·  5评论

Borkason picture Borkason  ·  4评论

nixoz2k7 picture nixoz2k7  ·  7评论