【发布时间】: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] 仍然没有返回私人回购。我没有正确提交令牌吗?
【问题讨论】:
-
这些信息对您的情况有用吗? stackoverflow.com/questions/20396329/…
标签: python github-api