如何通过 GitHub API 列出用户的 GitHub 存储库
How to list a user's GitHub repository via the GitHub API
我正在尝试通过 GitHub API 列出用户的私有存储库。我目前向 GitHub 提出的请求如下。
https://api.github.com/users/username/repos?sort=updated&direction=desc&visibility=all
它会 return 用户的存储库,但不会处理私人存储库。起初我认为问题出在我的 OAuth 令牌上的范围选项上。我目前在我的应用程序中有以下设置。
'user',
'repo',
'repo_deployment',
'admin:repo_hook',
'admin:org_hook',
但即使我在我的开发箱上设置了所有范围选项,我也会看到所有 public 个存储库,但 none 用户的私有存储库。我还尝试从 url 中删除所有参数。所以请求如下。
https://api.github.com/users/username/repos
这又没有return用户的私有存储库。
我正在尝试获取当前用户的私有存储库。但只有他们帐户下拥有的那些。
您为此使用了错误的端点。您在以下端点之后:
https://developer.github.com/v3/repos/#list-your-repositories
https://api.github.com/user/repos
List repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access. The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
我刚刚对其进行了测试,这 returns 您的私人存储库。
希望对您有所帮助。
您可能必须 authorize 自己获得列出您的私有存储库的许可。
获取 OAuth 令牌 from the account (or from the OAuth Authorizations API),然后将令牌添加为 GET 参数(在查询字符串 ?access_token=OAUTH-TOKEN
中)或 HTTP header (Authorization: token OAUTH-TOKEN
)您的请求,您可能已获得您的需要的许可。
我正在尝试通过 GitHub API 列出用户的私有存储库。我目前向 GitHub 提出的请求如下。
https://api.github.com/users/username/repos?sort=updated&direction=desc&visibility=all
它会 return 用户的存储库,但不会处理私人存储库。起初我认为问题出在我的 OAuth 令牌上的范围选项上。我目前在我的应用程序中有以下设置。
'user',
'repo',
'repo_deployment',
'admin:repo_hook',
'admin:org_hook',
但即使我在我的开发箱上设置了所有范围选项,我也会看到所有 public 个存储库,但 none 用户的私有存储库。我还尝试从 url 中删除所有参数。所以请求如下。
https://api.github.com/users/username/repos
这又没有return用户的私有存储库。
我正在尝试获取当前用户的私有存储库。但只有他们帐户下拥有的那些。
您为此使用了错误的端点。您在以下端点之后:
https://developer.github.com/v3/repos/#list-your-repositories
https://api.github.com/user/repos
List repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access. The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
我刚刚对其进行了测试,这 returns 您的私人存储库。
希望对您有所帮助。
您可能必须 authorize 自己获得列出您的私有存储库的许可。
获取 OAuth 令牌 from the account (or from the OAuth Authorizations API),然后将令牌添加为 GET 参数(在查询字符串 ?access_token=OAUTH-TOKEN
中)或 HTTP header (Authorization: token OAUTH-TOKEN
)您的请求,您可能已获得您的需要的许可。