fix(autoupdate): Ensure GitHub API requests use token (#6535)

This commit is contained in:
z-Fng
2026-01-06 13:31:19 +08:00
committed by GitHub
parent aa3f9aa983
commit bd2e93df63
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -17,6 +17,7 @@
- **scoop-uninstall:** Correct `-Global` Switch ([#6454](https://github.com/ScoopInstaller/Scoop/issues/6454))
- **scoop-update:** Force sync tags w/ remote branch while scoop update ([#6439](https://github.com/ScoopInstaller/Scoop/issues/6439))
- **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455))
- **autoupdate:** Ensure GitHub API requests use token ([#6535](https://github.com/ScoopInstaller/Scoop/issues/6535))
- **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/issues/6446))
- **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463))
- **getopt:** Teach getopt to respect the `--%` token ([#6477](https://github.com/ScoopInstaller/Scoop/issues/6477))
+6
View File
@@ -118,6 +118,12 @@ function find_hash_in_json([String] $url, [Hashtable] $substitutions, [String] $
$wc = New-Object Net.Webclient
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.Headers.Add('User-Agent', (Get-UserAgent))
if (($url -match '^https?://api\.github\.com/.*') -and (Get-GitHubToken)) {
$wc.Headers.Add('Authorization', "Bearer $(Get-GitHubToken)")
$wc.Headers.Add('X-GitHub-Api-Version', '2022-11-28')
}
$data = $wc.DownloadData($url)
$ms = New-Object System.IO.MemoryStream
$ms.Write($data, 0, $data.Length)