V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
weioyi
V2EX  ›  GitHub

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

  •  2
     
  •   weioyi · 2019-10-22 17:25:11 +08:00 · 9074 次点击
    这是一个创建于 1619 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题:

    • 公开库的 raw 格式是:

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

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

    • 私有库的 raw 格式是:

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

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

    尝试方法:

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

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

    https://[email protected]/[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 格式文件,请大佬赐教,或给个解决方法的链接。

    谢谢!

    第 1 条附言  ·  2019-10-22 18:13:08 +08:00

    谢谢各位回答。

    本题需要的是:用浏览器就可以查看 GitHub 私有库文件 raw 格式的命令(不是命令行等方式)。

    对于各位回答,我会一个一个测试,如果成功,会写出答案。

    再次感谢!

    34 条回复    2023-11-09 23:33:22 +08:00
    ETiV
        2
    ETiV  
       2019-10-22 17:57:15 +08:00 via iPhone
    GitHub 貌似支持 http basic auth 的样子
    生成一个 personal access token
    访问用 https://[user]:[token]@github.com/blahblah 这种 URL,后面没有 query 参数
    learnshare
        3
    learnshare  
       2019-10-22 18:39:45 +08:00
    weioyi
        4
    weioyi  
    OP
       2019-10-22 18:50:22 +08:00
    @learnshare 这个是用于公有库的。我需要的是用于私有库的。
    dorentus
        5
    dorentus  
       2019-10-23 01:16:02 +08:00 via iPhone
    用付费的 private repo 开 pages 提供 URL。
    quicysver
        6
    quicysver  
       2019-11-18 14:29:07 +08:00
    我最近也发现这个问题 不知道怎么解决
    weioyi
        7
    weioyi  
    OP
       2019-11-21 14:42:14 +08:00
    @quicysver 还没有解决
    uniconhlp
        8
    uniconhlp  
       2019-11-21 21:38:46 +08:00
    @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
        9
    Levox  
       2020-04-04 12:52:48 +08:00
    楼主解决了吗?
    KhaosChow
        10
    KhaosChow  
       2020-06-26 22:47:34 +08:00 via Android
    有人解决了吗?
    o0OoO0o
        11
    o0OoO0o  
       2020-11-28 18:02:14 +08:00
    同问,最后解决了吗?
    weioyi
        12
    weioyi  
    OP
       2020-12-12 10:04:06 +08:00
    @o0OoO0o 还没有解决
    mjollnir
        13
    mjollnir  
       2020-12-31 16:41:32 +08:00
    我测试下来这种方法可行
    curl https://[username]:[token]@raw.githubusercontent.com/[username]/[repo]/master/[xxxxxxx]
    weioyi
        14
    weioyi  
    OP
       2021-01-08 22:25:45 +08:00
    @mjollnir 测试了一下,还是不可以访问。

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

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

    谢谢:)
    Token3
        15
    Token3  
       2021-02-20 16:19:11 +08:00
    最近也遇到了这个问题,楼主最终解决这个问题了吗?
    AdoShan
        16
    AdoShan  
       2021-07-19 22:52:42 +08:00
    @dorentus 具体咋搞哇。我这是 Pro 账户
    jfgyjghrjry
        17
    jfgyjghrjry  
       2022-01-19 08:54:42 +08:00
    创建 oauth 令牌,raw 链接+?access_token=oauth 令牌即可
    jfgyjghrjry
        18
    jfgyjghrjry  
       2022-01-19 08:59:21 +08:00
    @jfgyjghrjry 刚刚试了一下,好像不可以了🤦‍♂️
    sunny2580839896
        19
    sunny2580839896  
       2022-04-29 16:13:44 +08:00
    解决了吗?
    Demoee
        20
    Demoee  
       2022-07-16 01:40:18 +08:00 via iPad
    围观求个解决方案
    qingyin
        21
    qingyin  
       2022-07-18 01:26:17 +08:00 via Android
    现在还有人解决吗
    VT2
        22
    VT2  
       2022-07-19 16:16:12 +08:00
    围观,也是试了半天都没有发现解决方案
    geekyouth
        23
    geekyouth  
       2022-07-29 15:04:25 +08:00
    同求
    eudemonwind
        24
    eudemonwind  
       2022-09-01 06:58:51 +08:00
    把文件加密了传公有库?
    shindgewongxj
        25
    shindgewongxj  
       2022-09-01 14:11:05 +08:00
    `https://<Personal Access Tokens>@raw.githubusercontent.com/<username>/<reponame>/<branchname>/<path>/<filename>`
    levine
        26
    levine  
       2022-10-06 14:43:17 +08:00
    @jfgyjghrjry 请问是 OAuth Apps 这个?还是 Personal access tokens 呢?
    levine
        27
    levine  
       2022-10-06 14:44:40 +08:00
    请问有解决嘛?或者有没有其他可以实现的网站呢?
    levine
        28
    levine  
       2022-10-07 09:52:26 +08:00
    @shindgewongxj 浏览器中操作不行哦。
    jfgyjghrjry
        29
    jfgyjghrjry  
       2022-10-19 13:21:46 +08:00
    @levine 我重新回复了我自己,这个操作已经已经无法使用了
    levine
        30
    levine  
       2022-10-21 17:08:15 +08:00
    @jfgyjghrjry 谢谢。
    yidongnan
        31
    yidongnan  
       2023-03-08 20:14:29 +08:00
    同求~
    sunny2580839896
        33
    sunny2580839896  
       2023-03-20 07:47:57 +08:00 via iPhone
    @Dragonphy 谢谢,最后用 gist 解决了
    yxmyxmyyy
        34
    yxmyxmyyy  
       140 天前
    去 cf worker 搭一个反代,反代带上 token 请求头就行了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3328 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:41 · PVG 08:41 · LAX 17:41 · JFK 20:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.