[英]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_token
或token
)。
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.