【发布时间】:2013-05-16 21:34:19
【问题描述】:
我需要从我的 GitHub 私人仓库下载一个文件。因此,按照 GitHub 网站上的说明,我为我的凭据创建了一个 OAuth 令牌。
然后我执行了这个 PS 脚本:
$WebClient = New-Object -TypeName System.Net.WebClient
$WebClient.Headers.Add('Authorization','{OAuth token}')
$uri = "https://github.com/mycompany/myrepo/blob/master/myfile.zip"
$targetPath = "c:\temp"
$WebClient.DownloadFile($uri, $targetPath)
但是,$WebClient.DownloadFile() 返回 404。这很奇怪,因为我可以通过使用与创建 OAuth 令牌相同的凭据登录到 GitHub 的浏览器从 $uri 检索文件。
【问题讨论】:
-
查看此站点以获取我当前的解决方案。 stackoverflow.com/questions/27951561/…
标签: powershell github powershell-3.0