feat(auth-oauth2): custom parameters for authorization, token, and refresh requests (#629)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Gregory SchierandClaude Opus 5 authored and GitHub committed 2026-09-13 09:15:25 -07:00
1 parent 7d0926c961
commit 7a6d275fdb
16 files changed
+771 -5

No files matched your search

+48
View File
@@ -11,6 +11,7 @@ import {
DEFAULT_LOCALHOST_PORT,
stopActiveServer,
} from "./callbackServer";
import { readCustomParams } from "./customParams";
import {
type CallbackType,
DEFAULT_PKCE_METHOD,
@@ -468,6 +469,48 @@ export const plugin: PluginDefinition = {
values.clientCredentialsMethod === "client_assertion",
}),
},
{
type: "key_value",
name: "authorizationParams",
label: "Authorization Params",
description: "Query params appended to the authorization URL.",
optional: true,
dynamic: hiddenIfNot(["authorization_code", "implicit"]),
},
{
type: "key_value",
name: "tokenHeaders",
label: "Token Headers",
description:
"Headers sent with the token request, and when refreshing unless overridden.",
optional: true,
dynamic: hiddenIfNot(["authorization_code", "password", "client_credentials"]),
},
{
type: "key_value",
name: "tokenBodyParams",
label: "Token Body Params",
description:
"Form params sent with the token request, and when refreshing unless overridden.",
optional: true,
dynamic: hiddenIfNot(["authorization_code", "password", "client_credentials"]),
},
{
type: "key_value",
name: "refreshHeaders",
label: "Refresh Headers",
description: "Headers sent only when refreshing the token.",
optional: true,
dynamic: hiddenIfNot(["authorization_code", "password"]),
},
{
type: "key_value",
name: "refreshBodyParams",
label: "Refresh Body Params",
description: "Form params sent only when refreshing the token.",
optional: true,
dynamic: hiddenIfNot(["authorization_code", "password"]),
},
],
},
{
@@ -506,6 +549,7 @@ export const plugin: PluginDefinition = {
const headerPrefix = stringArg(values, "headerPrefix");
const grantType = stringArg(values, "grantType") as GrantType;
const credentialsInBody = values.credentials === "body";
const customParams = readCustomParams(values);
const tokenName = values.tokenName === "id_token" ? "id_token" : "access_token";
// Build external browser options if enabled
@@ -546,6 +590,7 @@ export const plugin: PluginDefinition = {
: null,
tokenName: tokenName,
externalBrowser: externalBrowserOptions,
customParams,
});
} else if (grantType === "implicit") {
const authorizationUrl = stringArg(values, "authorizationUrl");
@@ -561,6 +606,7 @@ export const plugin: PluginDefinition = {
state: stringArgOrNull(values, "state"),
tokenName: tokenName,
externalBrowser: externalBrowserOptions,
customParams,
});
} else if (grantType === "client_credentials") {
const accessTokenUrl = stringArg(values, "accessTokenUrl");
@@ -577,6 +623,7 @@ export const plugin: PluginDefinition = {
scope: stringArgOrNull(values, "scope"),
audience: stringArgOrNull(values, "audience"),
credentialsInBody,
customParams,
});
} else if (grantType === "password") {
const accessTokenUrl = stringArg(values, "accessTokenUrl");
@@ -591,6 +638,7 @@ export const plugin: PluginDefinition = {
scope: stringArgOrNull(values, "scope"),
audience: stringArgOrNull(values, "audience"),
credentialsInBody,
customParams,
});
} else {
throw new Error(`Invalid grant type ${String(grantType)}`);