简体   繁体   English

Github使用访问令牌获取私人仓库

[英]Github GET on private repo with access token

I have a private repo in my org and I need to provide access. 我的组织中有一个私人仓库,我需要提供访问权限。 I want to be able to access a file through a GET request (the browser). 我希望能够通过GET请求(浏览器)访问文件。 I do NOT have a terminal or curl or any other tools. 我没有终端或卷曲或任何其他工具。

I created a dummy account that I linked to my org. 我创建了一个虚拟帐户,我链接到我的组织。 I went to https://github.com/settings/tokens and added one. 我去了https://github.com/settings/tokens并添加了一个。

Then I tried the following URLS 然后我尝试了以下URL

which does not work. 这不起作用。 It only seems to work with the generated token that you get when you click on "raw" on the github gui. 它似乎只与您在github gui上单击“raw”时获得的生成令牌一起使用。 Unfortunately this token expires quickly so it does not work for my application. 不幸的是,此令牌很快就会过期,因此它不适用于我的应用程序。

How do I access private resource on github with an access token through a URL ? 如何通过URL使用访问令牌访问github上的私有资源?

The API docs list that you can use the parameter access_token to pass in an oauth token (not private_token or token ). API文档列表,您可以使用参数access_token传入oauth令牌(而不是private_tokentoken )。

Does https://raw.githubusercontent.com/ORG/REPO/master/path/to/file.json?access_token=26cb4d8a30ca2 work for you? https://raw.githubusercontent.com/ORG/REPO/master/path/to/file.json?access_token=26cb4d8a30ca2适合您吗?

To fetch raw use: 要获取原始用途:

curl \
  -H 'Authorization: token <personal token gen value>' \
  https://raw.<host>/user/org/repo/pathtofile

To fetch through api: 要通过api获取:

curl \
  -H 'Authorization: token <personal token gen>' \
  -H 'Accept:application/vnd.github.VERSION.raw' \
  https://<host_name>/api/v3/repos/<user>/<repo_name>/contents/<path_to_file>/?ref=<branch>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用个人访问令牌 Netbeans 克隆私有 Github 回购 - Clone a Private Github Repo with a Personal Access Token Netbeans Github:只读访问私有仓库 - Github: readonly access to a private repo GitHub OAuth2 令牌:如何限制读取单个私人仓库的访问权限 - GitHub OAuth2 Token: How to restrict access to read a single private repo 如何使用个人访问令牌在 github 操作工作流 (B) 中从不同的存储库 (B) 提交和推送到私有存储库 (A) - How to commit and push to a private repo(A), from a different repo(B), in github actions workflow (B) , using personal access token Docker使用令牌更改.gitconfig以进行私有repo访问 - Docker change .gitconfig with token for private repo access Github 操作:如何从另一个组织访问私有仓库? - Github Action : How do I get access to Private repo from another organization? 如何为现有的私有仓库添加新的 github 令牌? - How to add a new github token for an existing private repo? github 克隆私有仓库 - github clone private repo 无法使用个人访问令牌访问私人 Git 回购 - Can't Access Private Git Repo With Personal Access Token 访问GitHub私有存储库时部署到EC2实例失败 - Deploying to ec2 instance failing when access GitHub private repo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM