【问题标题】:How can I pull private repo data using GitHub API?如何使用 GitHub API 拉取私有仓库数据?
【发布时间】:2019-02-07 04:05:42
【问题描述】:

我是一个组织的成员,该组织在 GitHub 上有很多私有存储库。我需要使用 GitHub API 从私有存储库中获取数据。我正在使用以下 python 代码:

url = "https://api.github.com/orgs/myorg/repos?access_token=[mytokenhere]"
headers = {"Authorization": "token [myPATHhere]"}
session = requests.Session()
response = session.get(url, headers = headers)
content = response.text

my_json = json.loads(response.text)


for item in my_json:
    print(item['html_url'])

其中 PAT = 我的访问令牌。这仍然只返回公共存储库。我见过related question,但列出的解决方案并不能解决我的问题。请注意,我已授权我的访问令牌进入私有存储库。我也试过 api.github.com/users/repos 和 api.github.com/users/[myorghere] 仍然没有返回私人回购。我没有正确提交令牌吗?

【问题讨论】:

标签: python github-api


【解决方案1】:

进入您的个人访问令牌并确保您已选择必要的范围。第一个用于私人回购,因此您可能需要在那里选择部分/全部选项。

【讨论】:

    猜你喜欢
    • 2012-10-19
    • 2020-01-05
    • 2012-08-13
    • 2018-06-16
    • 1970-01-01
    • 2022-06-28
    • 2019-12-19
    • 2018-01-15
    • 1970-01-01
    相关资源
    最近更新 更多