mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5575] feat: auto oauth2 token generation for collection runner and cli #5264
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5264
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5575
Author: @Leon-Luu
Created: 11/12/2025
Status: 🔄 Open
Base:
main← Head:feat/auto_oath2_on_collection_run📝 Commits (10+)
76ebaebfeat: add auto oath2.0 generate from collection runner614d62dfix: toast referencede43709chore: add test for auto oauth2 runner9fba217feat: add cli support for outh2 colection level token generator0381829chore: fix copilot reviews66a9ce1fix: populate env variables correctly to the cli collection runcdfe93ffix: improve OAuth auto-token-generator type safety1d6b52cfeat: re-factor with unifying cli and ui to use same oauth generators0208a83fix: resolve test runner OAuth issues for team workspace collections152755ffeat: add auto oath2.0 generate from collection runner📊 Changes
15 files changed (+2112 additions, -38 deletions)
View changed files
📝
packages/hoppscotch-cli/src/__tests__/e2e/commands/__snapshots__/test.spec.ts.snap(+4 -4)📝
packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts(+1 -1)➕
packages/hoppscotch-cli/src/__tests__/unit/oauth/token-generator.spec.ts(+490 -0)📝
packages/hoppscotch-cli/src/utils/collections.ts(+81 -2)➕
packages/hoppscotch-cli/src/utils/oauth/token-generator.ts(+336 -0)📝
packages/hoppscotch-cli/src/utils/workspace-access.ts(+19 -12)📝
packages/hoppscotch-common/locales/en.json(+5 -1)📝
packages/hoppscotch-common/src/components/http/test/Runner.vue(+47 -10)➕
packages/hoppscotch-common/src/helpers/oauth/auto-token-generator.ts(+184 -0)📝
packages/hoppscotch-common/src/services/oauth/flows/password.ts(+6 -3)➕
packages/hoppscotch-common/src/services/test-runner/__tests__/test-runner-oauth.spec.ts(+688 -0)📝
packages/hoppscotch-common/src/services/test-runner/test-runner.service.ts(+67 -4)📝
packages/hoppscotch-data/src/environment/index.ts(+2 -1)📝
packages/hoppscotch-data/src/index.ts(+1 -0)➕
packages/hoppscotch-data/src/utils/oauth.ts(+181 -0)📄 Description
This implementation adds automatic OAuth 2.0 token generation at the start of collection runs in Hoppscotch. The feature eliminates the need for manual token generation before running collections, streamlining the workflow and improving reliability. Implements automatic OAuth token generation for CLI collections, matching UI runner functionality.
Before This Feature
After This Feature
Benefits
1. Streamlined Workflow
2. Consistency
3. Reliability
4. Automation-Ready
✅ Supported Grant Types (Automatic Generation)
Client Credentials
Password (Resource Owner Password Credentials)
⚠️ Not Supported (Requires Manual Token Generation)
Authorization Code
Implicit
Closes #
https://github.com/hoppscotch/hoppscotch/issues/5478
Implementation Flow (UI collection runner)
Implementation Flow (CLI mode)
Technical Details
Token Generation Process
Error Handling
The implementation provides specific error messages for:
no_config_found)redirect_not_supported_for_collection)auto_generation_validation_failed)token_fetch_failed)unsupported_grant_type_for_auto_generation)Each error displays a user-friendly toast message and stops collection execution.
What's changed
packages/hoppscotch-common/src/helpers/oauth/auto-token-generator.tshasOAuth2Auth()- Checks if collection has OAuth configuredrequiresRedirect()- Checks if grant type needs browser redirectgenerateOAuth2TokenForCollection()- Main function to generate tokensupdateCollectionWithToken()- Updates collection with generated tokenNotes to reviewers
Summary by cubic
Automatically generates OAuth 2.0 tokens at the start of collection runs in both UI and CLI. Removes manual token steps and improves reliability for long runs and CI.
New Features
Migration
Written for commit
56cfd314cf. Summary will update automatically on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.