GitHub 私有库,如何**长久的**读取文件的 raw 格式。

2019 年 10 月 22 日
 weioyi

问题:

https://raw.githubusercontent.com/[user]/repo/path/file

这个格式的网址是长久可以访问的。

https://raw.githubusercontent.com/[user]/repo/path/file?token=xxxxxxxxxxxxxxxxx

这个是临时访问网址,过一会就不能访问了。

尝试方法:

然后在网上找了一些格式,也不能访问,测试格式如下:

https://raw.githubusercontent.com/[user]/repo/path/file?token=OAUTH-TOKEN

https://OAUTH-TOKEN@github.com/[user]/repo/path/file

https://rawgit.com/[user]/repo/path/file?token=OAUTH-TOKEN

https://api.github.com/[user]/repo/path/file?access_token=OAUTH-TOKEN

https://api.github.com/[user]/repo/path/file?client_id=MY-CLIENT-ID&client_secret=MY-CLIENT-SECRET

请赐教:

如何像公开库一样( HTTP 方式),实现长久访问私有库的 raw 格式文件,请大佬赐教,或给个解决方法的链接。

谢谢!

12808 次点击
所在节点    GitHub
35 条回复
U7Q5tLAex2FI0o0g
2019 年 10 月 22 日
ETiV
2019 年 10 月 22 日
GitHub 貌似支持 http basic auth 的样子
生成一个 personal access token
访问用 https://[user]:[token]@github.com/blahblah 这种 URL,后面没有 query 参数
learnshare
2019 年 10 月 22 日
weioyi
2019 年 10 月 22 日
@learnshare 这个是用于公有库的。我需要的是用于私有库的。
dorentus
2019 年 10 月 23 日
用付费的 private repo 开 pages 提供 URL。
quicysver
2019 年 11 月 18 日
我最近也发现这个问题 不知道怎么解决
weioyi
2019 年 11 月 21 日
@quicysver 还没有解决
uniconhlp
2019 年 11 月 21 日
@weioyi Github 的 api 还没研究,不过目前 gitlab 的私有库查看 raw 文件格式倒是 OK 了: https://gitlab.com/api/v4/projects/:id/repository/files/yyyyy%2Fxxxxxx.conf/raw?ref=master&private_token=xxxxxxxxxxx

exp:查看仓库 id:id 下的 yyyyy 目录中的 xxxxxx.conf 源文件。ref=master 必须选择分支。private_token 同 GitHub 一样申请。希望有用。
Levox
2020 年 4 月 4 日
楼主解决了吗?
KhaosChow
2020 年 6 月 26 日
有人解决了吗?
o0OoO0o
2020 年 11 月 28 日
同问,最后解决了吗?
weioyi
2020 年 12 月 12 日
@o0OoO0o 还没有解决
mjollnir
2020 年 12 月 31 日
我测试下来这种方法可行
curl https://[username]:[token]@raw.githubusercontent.com/[username]/[repo]/master/[xxxxxxx]
weioyi
2021 年 1 月 8 日
@mjollnir 测试了一下,还是不可以访问。

1.请问您这个测试的是私有库吗?
2.私有库对于创建的 raw 格式超链接有时间限制。时间过了就不能访问了。

如果您测试后还是可行,请告知。

谢谢:)
Token3
2021 年 2 月 20 日
最近也遇到了这个问题,楼主最终解决这个问题了吗?
AdoShan
2021 年 7 月 19 日
@dorentus 具体咋搞哇。我这是 Pro 账户
jfgyjghrjry
2022 年 1 月 19 日
创建 oauth 令牌,raw 链接+?access_token=oauth 令牌即可
jfgyjghrjry
2022 年 1 月 19 日
@jfgyjghrjry 刚刚试了一下,好像不可以了🤦‍♂️
univ
2022 年 4 月 29 日
解决了吗?
Demoee
2022 年 7 月 16 日
围观求个解决方案

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/611818

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX