Skip to content

fix(workers): use configured OAUTH_TOKEN_URL for proactive refresh - #2

Open
DjWarmonger wants to merge 1 commit into
iceener:mainfrom
DjWarmonger:fix/workers-refresh-token-endpoint-path
Open

fix(workers): use configured OAUTH_TOKEN_URL for proactive refresh#2
DjWarmonger wants to merge 1 commit into
iceener:mainfrom
DjWarmonger:fix/workers-refresh-token-endpoint-path

Conversation

@DjWarmonger

@DjWarmonger DjWarmonger commented Jul 9, 2026

Copy link
Copy Markdown

Problem

buildProviderRefreshConfig() in the Workers adapter (src/adapters/http-workers/mcp.handler.ts) returns only clientId, clientSecret, and accountsUrl — it omits tokenEndpointPath. As a result, refreshProviderToken() falls back to the default token path and POSTs proactive refreshes to the provider accounts host instead of the configured token endpoint (OAUTH_TOKEN_URL).

For providers whose token endpoint differs from the accounts host (e.g. Linear: accounts on linear.app, token endpoint on api.linear.app), proactive refresh hits the wrong host and fails, so provider-token expiry never self-heals and later surfaces as an opaque "Authentication required" error.

Fix

Wire tokenEndpointPath from config.OAUTH_TOKEN_URL in the Workers adapter's buildProviderRefreshConfig(), so proactive refresh targets the configured endpoint.

The Hono adapter is unaffected — it already uses the shared buildProviderRefreshConfig() in src/shared/oauth/refresh.ts, which sets this correctly. This one-line change brings the Workers adapter in line with it.

buildProviderRefreshConfig() in the Workers adapter omitted tokenEndpointPath,
so refreshProviderToken() fell back to the default token path and POSTed to the
provider accounts host instead of the configured token endpoint. Wire
tokenEndpointPath from config.OAUTH_TOKEN_URL so proactive refresh hits the
configured endpoint. (The Hono adapter already uses the shared
buildProviderRefreshConfig() in src/shared/oauth/refresh.ts, which sets this.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant