Skip to content

feat(download): Enhance Get-GitHubToken to include more token sources - #6712

Merged
niheaven merged 3 commits into
ScoopInstaller:developfrom
lisonge:patch-1
Aug 21, 2026
Merged

niheaven merged 3 commits into
ScoopInstaller:developfrom
lisonge:patch-1

Conversation

@lisonge

@lisonge lisonge commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

https://cli.github.com/manual/gh_help_environment

> gh --help environment | grep '_TOKEN'
`GH_TOKEN`, `GITHUB_TOKEN` (in order of precedence): an authentication token that will be used when
`GH_ENTERPRISE_TOKEN`, `GITHUB_ENTERPRISE_TOKEN` (in order of precedence): an authentication
authenticated with, the stored credentials will be used. Otherwise, setting `GH_TOKEN` or
`GH_ENTERPRISE_TOKEN` is required, depending on the targeted host.

This pull request makes a small update to the Get-GitHubToken function in lib/download.ps1 to improve how GitHub authentication tokens are retrieved.

  • The function now checks two additional environment variables, GH_TOKEN and GITHUB_TOKEN, in addition to the previously checked variables, to find a valid GitHub token for authentication.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 64fe0da6-7ede-4567-b876-0251627963ef

📥 Commits

Reviewing files that changed from the base of the PR and between 6247aff and ea10211.

📒 Files selected for processing (1)
  • CHANGELOG.md

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Summary by CodeRabbit

  • Bug Fixes

    • GitHub downloads can now authenticate using the GH_TOKEN or GITHUB_TOKEN environment variables when other configured token sources are unavailable.
    • Download and checksum failures now provide clearer diagnostic context.
    • Aria2 fallback errors now report consistent troubleshooting details.
    • Successful checksum output is displayed in uppercase for improved readability.
  • New Features

    • Aria2 fallback can be disabled to stop immediately when the primary download fails.

Walkthrough

Download failures now report issue context, aria2 fallback can be disabled, and download output formatting is updated. Get-GitHubToken also checks GH_TOKEN and GITHUB_TOKEN.

Changes

Download handling

Layer / File(s) Summary
Download failure and fallback control
lib/download.ps1
Download failures now include generated issue diagnostics. Setting ARIA2-FALLBACK-DISABLED aborts after an aria2 failure; otherwise, fallback remains available.
Download and hash output formatting
lib/download.ps1
Aria2 and hash-check messages use updated cyan formatting and ellipsis spacing. Successful hash verification now reports OK..

GitHub token resolution

Layer / File(s) Summary
Additional token sources
lib/download.ps1, CHANGELOG.md
Get-GitHubToken checks GH_TOKEN and GITHUB_TOKEN after the existing sources and returns the first non-empty token. The changelog records this enhancement.

Merge Risk: 🔵 Low · up to ea102

The change broadens GitHub authentication lookup to support GH_TOKEN and GITHUB_TOKEN. The branch remains mergeable with owner awareness that diagnostics may expose sensitive connection data and some download failures may be reported with misleading error text; these issues should receive follow-up.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change to add more token sources to Get-GitHubToken.
Description check ✅ Passed The description directly explains the Get-GitHubToken changes and the added GH_TOKEN and GITHUB_TOKEN environment variables.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitfool

gitfool commented Aug 19, 2026

Copy link
Copy Markdown

Better yet, check for and run gh auth token, as was suggested in #6716, which would be similar to what homebrew does.

@niheaven

Copy link
Copy Markdown
Member

Please target to develop branch

@lisonge
lisonge changed the base branch from master to develop August 21, 2026 11:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
lib/download.ps1 (3)

456-465: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Remove secrets from aria2 diagnostics.

When cookies or proxy credentials are configured, $aria2 contains Cookie values and --all-proxy-passwd values from the options built at Lines 364-377. The new error $aria2 and warn $aria2 statements print these values. $urlstxt_content can also contain signed URLs. Redact credentials and URL tokens before output, or report only sanitized metadata.


24-27: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use an accurate failure message for download exceptions.

Invoke-CachedDownload can fail because of authentication, timeouts, network errors, or file I/O. Both catch blocks report every failure as URL $url is not valid. Report a generic download failure or classify the exception before reporting it.

Also applies to: 473-476


456-476: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Move aria2 cleanup into finally.

When abort runs at lines 460 or 476, it exits before removing $urlstxt and .aria2 control files. Place temporary-file cleanup and console restoration in a finally block around the aria2 and fallback operations.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8319e1a4-1476-4656-9514-3d93d1f4f4a1

📥 Commits

Reviewing files that changed from the base of the PR and between 28bac55 and 6247aff.

📒 Files selected for processing (1)
  • lib/download.ps1

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@niheaven niheaven changed the title feat: Enhance Get-GitHubToken to include more token sources feat(download): Enhance Get-GitHubToken to include more token sources Aug 21, 2026
@niheaven
niheaven merged commit a36c842 into ScoopInstaller:develop Aug 21, 2026
2 checks passed
@refack

refack commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Better yet, check for and run gh auth token, as was suggested in #6716, which would be similar to what homebrew does.

see #6725
😊

@niheaven niheaven mentioned this pull request Sep 12, 2026
2 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants