Skip to content

feat(opencode): add MiniMax OAuth device code flow plugin#27011

Open
jiemu-minimax wants to merge 13 commits into
anomalyco:devfrom
jiemu-minimax:feat/minimax-oauth
Open

feat(opencode): add MiniMax OAuth device code flow plugin#27011
jiemu-minimax wants to merge 13 commits into
anomalyco:devfrom
jiemu-minimax:feat/minimax-oauth

Conversation

@jiemu-minimax
Copy link
Copy Markdown

Issue for this PR

N/A — New provider integration

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Add MiniMax (MiniMax) as an OAuth provider, supporting both global (api.minimax.io) and China domestic (api.minimaxi.com) regions.

  • Implements OAuth 2.0 Device Code Flow (RFC 8628) with PKCE
  • Supports proactive token refresh (5-min buffer before expiry)
  • Auto-opens browser for user authorization
  • Propagates BEDROCK_LANE and X-User-Pre headers for test/pre-production environments
  • Registers both MinimaxAuthPlugin and MinimaxCnAuthPlugin

How did you verify your code works?

Tested OAuth login flow end-to-end in both global and CN regions, verified token refresh and API calls with the obtained access token.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

hatriotism added 11 commits May 12, 2026 14:20
- Implement MinimaxAuthPlugin with full device authorization grant flow
- PKCE (code_verifier + code_challenge via SHA-256) for security
- State parameter generated and verified to prevent CSRF
- Polls /oauth/token at server-specified interval until authorized
- Proactive token refresh 60s before expiry with refresh_token rotation
- Stores resource_url in enterpriseUrl field for AI API base URL
Match mmx-cli's 5-minute refresh buffer for consistency across
all MiniMax OAuth clients. 60s was too tight — network latency
could cause mid-request token expiry.
- Content-Type: JSON → application/x-www-form-urlencoded (OAuth standard)
- grant_type: user_code → device_code (RFC 8628 standard)
- Add scope parameter to device code request
- Add polling timeout based on expired_in (was infinite loop)
- Remove response_type from device code request (unused by server)
- OAuth: "Log in with MiniMax (OAuth)"
- API key: "Manually enter Token Plan key"
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Feat/minimax oauth doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 12, 2026
@jiemu-minimax jiemu-minimax changed the title Feat/minimax oauth feat(opencode): add MiniMax OAuth device code flow plugin May 12, 2026
@github-actions github-actions Bot removed needs:title needs:compliance This means the issue will auto-close after 2 hours. labels May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

2 participants