From bd2e93df635de0538ff2afc3dd3bb5a792e956a2 Mon Sep 17 00:00:00 2001 From: z-Fng <54583083+z-Fng@users.noreply.github.com> Date: Tue, 6 Jan 2026 00:31:19 -0500 Subject: [PATCH] fix(autoupdate): Ensure GitHub API requests use token (#6535) --- CHANGELOG.md | 1 + lib/autoupdate.ps1 | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e756db5..dc60da85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index fbc3ebfd..5ed0387b 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -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)