Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions open-sse/services/tokenRefresh.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CLAUDE_CONFIG } from "@/lib/oauth/constants/oauth";
import { PROVIDERS, OAUTH_ENDPOINTS } from "../config/constants.ts";
import { pbkdf2Sync } from "node:crypto";
import { runWithProxyContext } from "../utils/proxyFetch.ts";
Expand Down Expand Up @@ -226,6 +227,7 @@ export async function refreshClaudeOAuthToken(refreshToken, log, proxyConfig = n
grant_type: "refresh_token",
refresh_token: refreshToken,
client_id: PROVIDERS.claude.clientId,
scope: CLAUDE_CONFIG.scopes.join(" "),
};

const makeRequest = (contentType, extraHeaders = {}) =>
Expand Down
1 change: 1 addition & 0 deletions tests/unit/oauth-providers-config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ test("device and import-token providers expose the flow-specific fields expected
});

test("provider-specific config shapes remain valid for special cases", () => {
assert.equal(CLAUDE_CONFIG.redirectUri, "https://platform.claude.com/oauth/code/callback");

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

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

This assertion hard-codes Claude’s default redirect URI, but the test setup does not clear process.env.CLAUDE_CODE_REDIRECT_URI. If that env var is set in the environment running the unit tests, CLAUDE_CONFIG.redirectUri will not equal the default and this test will fail. Consider either explicitly deleting/unsetting CLAUDE_CODE_REDIRECT_URI in the env setup for this file, or asserting CLAUDE_CONFIG.redirectUri equals process.env.CLAUDE_CODE_REDIRECT_URI || "https://platform.claude.com/oauth/code/callback" to keep the test hermetic.

Suggested change
assert.equal(CLAUDE_CONFIG.redirectUri, "https://platform.claude.com/oauth/code/callback");
assert.equal(
CLAUDE_CONFIG.redirectUri,
process.env.CLAUDE_CODE_REDIRECT_URI || "https://platform.claude.com/oauth/code/callback"
);

Copilot uses AI. Check for mistakes.
assert.ok(Array.isArray(CLAUDE_CONFIG.scopes) && CLAUDE_CONFIG.scopes.length > 0);
assert.ok(Array.isArray(GEMINI_CONFIG.scopes) && GEMINI_CONFIG.scopes.length > 0);
assert.ok(Array.isArray(ANTIGRAVITY_CONFIG.scopes) && ANTIGRAVITY_CONFIG.scopes.length > 0);
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/token-refresh-service.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ test("refreshClaudeOAuthToken first matches Claude auth exchange token contract"
grant_type: "refresh_token",
refresh_token: "claude-refresh",
client_id: PROVIDERS.claude.clientId,
scope:
"org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers",
});
});

Expand Down Expand Up @@ -352,6 +354,7 @@ test("refreshClaudeOAuthToken retries with user-agent JSON then form when format
assert.equal(calls[2].options.headers["Content-Type"], "application/x-www-form-urlencoded");
assert.match(calls[2].options.body, /grant_type=refresh_token/);
assert.match(calls[2].options.body, /client_id=/);
assert.match(calls[2].options.body, /scope=org%3Acreate_api_key/);
});

test("refreshGoogleToken exchanges refresh tokens against the shared google endpoint", async () => {
Expand Down
Loading