Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(cli): nest custom credentials under auth_config.credentials in auth-configs create (#4063)

Azharc3623cb89825
diff --git a/ts/packages/cli/CHANGELOG.md b/ts/packages/cli/CHANGELOG.md
index 8c552e307..2822cfcfd 100644
--- a/ts/packages/cli/CHANGELOG.md
+++ b/ts/packages/cli/CHANGELOG.md
@@ -2,6 +2,11 @@
## Unreleased
+### Patch Changes
+
+- `composio dev auth-configs create` now sends custom OAuth credentials and scopes
+ in the API's expected shape instead of failing validation.
+
## 0.3.3
### Patch Changes
diff --git a/ts/packages/cli/src/commands/auth-configs/commands/auth-configs.create.cmd.ts b/ts/packages/cli/src/commands/auth-configs/commands/auth-configs.create.cmd.ts
index 684b6ca8b..0a46fab83 100644
--- a/ts/packages/cli/src/commands/auth-configs/commands/auth-configs.create.cmd.ts
+++ b/ts/packages/cli/src/commands/auth-configs/commands/auth-configs.create.cmd.ts
@@ -87,15 +87,20 @@ export const authConfigsCmd$Create = Command.make(
let params: AuthConfigCreateParams;
if (Option.isSome(authScheme)) {
- // Custom auth mode — spread user-provided credentials FIRST so explicit fields always win
+ // Custom credentials must be nested under `credentials` for the API to accept them.
params = {
toolkit: { slug: toolkit },
auth_config: {
- ...parsedCustomCredentials,
type: 'use_custom_auth' as const,
authScheme: authScheme.value as AuthConfigCreateParams.UnionMember1['authScheme'],
name: nameValue,
- credentials: scopesList ? { scopes: scopesList } : undefined,
+ credentials:
+ parsedCustomCredentials || scopesList
+ ? {
+ ...(parsedCustomCredentials ?? {}),
+ ...(scopesList ? { scopes: scopesList } : {}),
+ }
+ : undefined,
},
};
} else {
diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.ts
index 58190ecb9..ed1dcfcd6 100644
--- a/ts/packages/cli/test/__utils__/services/test-layer.ts
+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts
@@ -1,6 +1,7 @@
import path from 'node:path';
import * as tempy from 'tempy';
import { Composio as RawComposioClient } from '@composio/client';
+import type { AuthConfigCreateParams } from '@composio/client/resources/auth-configs';
import { CliApp, CliConfig } from '@effect/cli';
import { Command, FetchHttpClient, FileSystem, Path } from '@effect/platform';
import { BunFileSystem, BunContext, BunPath } from '@effect/platform-bun';
@@ -114,6 +115,7 @@ toolkitsData?: {
authConfigsData?: {
items?: AuthConfigItem[];
createResponse?: AuthConfigCreateResponse;
+ onCreate?: (params: AuthConfigCreateParams) => void;
};
/**
@@ -611,13 +613,15 @@ export const TestLayer = (input?: TestLiveInput) =>
}
return Effect.succeed(found);
},
- createAuthConfig: () =>
- Effect.succeed(
+ createAuthConfig: (params: AuthConfigCreateParams) => {
+ authConfigsData.onCreate?.(params);
+ return Effect.succeed(
authConfigsData.createResponse ?? {
auth_config: { id: 'ac_test', auth_scheme: 'OAUTH2', is_composio_managed: true },
toolkit: { slug: 'test' },
}
- ),
+ );
+ },
deleteAuthConfig: (nanoid: string) => {
const found = authConfigsData.items.find(item => item.id === nanoid);
if (!found) {
diff --git a/ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts b/ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts
index f84105c2c..305983fda 100644
--- a/ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, layer } from '@effect/vitest';
+import type { AuthConfigCreateParams } from '@composio/client/resources/auth-configs';
import { ConfigProvider, Effect } from 'effect';
import { extendConfigProvider } from 'src/services/config';
import { cli, TestLive, MockConsole } from 'test/__utils__';
@@ -181,4 +182,60 @@ describe('CLI: composio dev auth-configs create', () => {
);
}
);
+
+ let capturedCreateAuthConfig: AuthConfigCreateParams | undefined;
+
+ layer(
+ TestLive({
+ baseConfigProvider: testConfigProvider,
+ ...dangerousDevConfig,
+ authConfigsData: {
+ createResponse: {
+ auth_config: { id: 'ac_oauth', auth_scheme: 'OAUTH2', is_composio_managed: false },
+ toolkit: { slug: 'shopify' },
+ },
+ onCreate: params => {
+ capturedCreateAuthConfig = params;
+ },
+ },
+ })
+ )(
+ '[Given] custom OAuth credentials and scopes [Then] nests them under auth_config.credentials',
+ it => {
+ it.scoped('sends custom OAuth settings inside credentials', () =>
+ Effect.gen(function* () {
+ capturedCreateAuthConfig = undefined;
+
+ yield* cli([
+ 'dev',
+ 'auth-configs',
+ 'create',
+ '--toolkit',
+ 'shopify',
+ '--auth-scheme',
+ 'OAUTH2',
+ '--custom-credentials',
+ '{"client_id":"my_client_id","client_secret":"my_client_secret"}',
+ '--scopes',
+ 'read_products, write_products',
+ '--dangerously-allow',
+ ]);
+
+ expect(capturedCreateAuthConfig).toStrictEqual({
+ toolkit: { slug: 'shopify' },
+ auth_config: {
+ type: 'use_custom_auth',
+ authScheme: 'OAUTH2',
+ name: undefined,
+ credentials: {
+ client_id: 'my_client_id',
+ client_secret: 'my_client_secret',
+ scopes: ['read_products', 'write_products'],
+ },
+ },
+ });
+ })
+ );
+ }
+ );
});