[PR #9949] fix(provider): add OAuth token refresh support for GitLab provider #13281

Open
opened 2026-02-16 18:18:08 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9949

State: open
Merged: No


What

Add automatic token refresh when GitLab OAuth tokens expire during a session.

How verified

  • Code review of the implementation
  • The fix adds a new refresh hook to the plugin interface that allows auth plugins to handle token refresh
  • The gitlab provider's custom fetch now:
    1. Proactively checks if tokens are expired before making requests
    2. Handles 401 "invalid_token" errors by attempting refresh and retry

Changes

  • packages/plugin/src/index.ts: Add refresh function to AuthHook interface
  • packages/opencode/src/provider/auth.ts: Add ProviderAuth.refresh() to invoke plugin refresh logic
  • packages/opencode/src/provider/provider.ts: Add custom fetch in gitlab loader with token refresh handling

Note

This requires the external GitLab auth plugin (@gitlab/opencode-gitlab-auth) to implement the new refresh hook to provide the actual token refresh logic.

Fixes #9711

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9949 **State:** open **Merged:** No --- ## What Add automatic token refresh when GitLab OAuth tokens expire during a session. ## How verified - Code review of the implementation - The fix adds a new `refresh` hook to the plugin interface that allows auth plugins to handle token refresh - The gitlab provider's custom `fetch` now: 1. Proactively checks if tokens are expired before making requests 2. Handles 401 "invalid_token" errors by attempting refresh and retry ## Changes - **packages/plugin/src/index.ts**: Add `refresh` function to `AuthHook` interface - **packages/opencode/src/provider/auth.ts**: Add `ProviderAuth.refresh()` to invoke plugin refresh logic - **packages/opencode/src/provider/provider.ts**: Add custom `fetch` in gitlab loader with token refresh handling ## Note This requires the external GitLab auth plugin (`@gitlab/opencode-gitlab-auth`) to implement the new `refresh` hook to provide the actual token refresh logic. Fixes #9711 🤖 Generated with Claude Code
yindo added the pull-request label 2026-02-16 18:18:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13281