Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GitHub原始URL是否过期?_Github - Fatal编程技术网

GitHub原始URL是否过期?

GitHub原始URL是否过期?,github,Github,私有存储库的GitHub原始URL是否过期?我指的是在github.com上查看文件时单击Raw按钮时生成的链接 该链接包含一个令牌,但没有关于该令牌来自何处的信息。该令牌来自何处 https://:x-oauth-basic@raw.githubusercontent.com///主人/ raw.githubusercontent.com///master//部分未过期。 但是,在点击GitHub页面上的“Raw”之前键入“y”,以便将SHA1作为url的一部分:这样,您就可以确保始终引用相

私有存储库的GitHub原始URL是否过期?我指的是在github.com上查看文件时单击
Raw
按钮时生成的链接

该链接包含一个令牌,但没有关于该令牌来自何处的信息。

该令牌来自何处

https://:x-oauth-basic@raw.githubusercontent.com///主人/
raw.githubusercontent.com///master//
部分未过期。
但是,在点击GitHub页面上的“Raw”之前键入“y”,以便将SHA1作为url的一部分:这样,您就可以确保始终引用相同的文件版本

https://<oauth-secret>:x-oauth-basic@raw.githubusercontent.com/<me>/<repo>/<sha1>/<file>
                              ^                                             ^^^^
https://:x-oauth-basic@raw.githubusercontent.com////
^                                             ^^^^

(但可以删除或撤销)

请查看此API文档

URL应为:

curl -H 'Accept: application/vnd.github.VERSION.raw' -k \
https://{{githubhost}}/api/v3/repos/{{org}}/{{repo}}/contents/{{path}}?access_token=xxxx
这对我很有用:

  • 访问令牌是个人访问令牌
  • 路径可以是文件或目录

    • 没有人明确提到这一点,但是

      您可以使用此处生成的持续时间更长的个人访问令牌:但这些令牌只能通过curl使用:

      curl -H 'Authorization: token <personal_token>' <raw_url>
      
      curl-H“授权:令牌”
      

      请注意,个人访问令牌如果全年未使用,则会过期。

      原始URL末尾的令牌似乎会过期。有没有办法防止这种情况发生?不确定:你可以把它当作一个问题来问。这个问题曾经被问过吗?由于github不支持git归档,我们不得不用某种方式来处理oauth,因为原始文件会过期。我想要它easy@vonGohren我相信,但没有令人满意的答案。每当文件更改时,您将获得一个新令牌。因此,从2021年6月开始,这应该是公认的答案。在这一点上,最初的问题和被接受的答案已经有5年历史了,此后发生了很多变化。这种方法应该适用于任何基于请求的工具,而不仅仅是cURL。只需添加头
      Authorization:token
      
      curl -H 'Authorization: token <personal_token>' <raw_url>