Skip to content

feat: add Instagram connector support#397

Merged
sweetmantech merged 2 commits into
testfrom
feature/add-instagram-connector
Apr 6, 2026
Merged

feat: add Instagram connector support#397
sweetmantech merged 2 commits into
testfrom
feature/add-instagram-connector

Conversation

@recoup-coding-agent

@recoup-coding-agent recoup-coding-agent commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add "instagram" to SUPPORTED_TOOLKITS and ALLOWED_ARTIST_CONNECTORS
  • Add COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID auth config for Instagram OAuth
  • Fix authConfigs bug: moved auth config construction above both return paths so custom OAuth configs apply regardless of account_id presence
  • Part of REC-49: Add Instagram Connector (Artist-Level)

Test plan

  • Set COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID in env
  • Verify GET /api/connectors returns Instagram in artist connector list
  • Verify POST /api/connectors/authorize with connector: "instagram" includes auth config
  • Verify TikTok connector still works (regression)

🤖 Generated with Claude Code


Summary by cubic

Add an artist-level Instagram connector with custom OAuth, and apply authConfigs with or without account_id (REC-49).

  • New Features

    • Added "instagram" to SUPPORTED_TOOLKITS and ALLOWED_ARTIST_CONNECTORS.
    • Enabled Instagram OAuth via COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID.
  • Bug Fixes

    • Built authConfigs before all return paths so custom OAuth applies regardless of account_id; updated tests to include Instagram.

Written for commit f365475. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Instagram connector is now available in the Composio toolkit library for creating and managing sessions
    • Instagram is now supported and recognized as an allowed artist connector
  • Improvements

    • Enhanced OAuth authentication configuration handling for custom OAuth providers to ensure proper support for Instagram, TikTok, and other platforms

- Add "instagram" to SUPPORTED_TOOLKITS and ALLOWED_ARTIST_CONNECTORS
- Add COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID to authConfigs
- Fix bug: move authConfigs construction above both return paths so
  custom OAuth configs apply regardless of account_id presence

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Apr 6, 2026 3:59pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Instagram toolkit support has been added to the Composio connector system across three related modules. Configuration additions extend the allowed artist connectors list to include Instagram. OAuth configuration logic in authorization handling was refactored to reduce duplication.

Changes

Cohort / File(s) Summary
Instagram Connector Registration
lib/composio/connectors/getConnectors.ts
Added instagram slug to the exported toolkit list for connector discovery.
Artist Connector Authorization
lib/composio/connectors/isAllowedArtistConnector.ts
Extended ALLOWED_ARTIST_CONNECTORS constant to recognize instagram alongside tiktok; AllowedArtistConnector type updated accordingly.
OAuth Configuration Refactoring
lib/composio/connectors/validateAuthorizeConnectorRequest.ts
Extracted common authConfigs construction logic for tiktok and instagram providers into a shared step outside conditional branches, eliminating duplication between account-provided and authenticated-account paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

📸 Instagram joins the connector crew,
TikTok no longer dances alone—
Refactored OAuth, cleaner and true,
Duplication dissolved, maintainability shown! 🎬✨

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Solid & Clean Code ✅ Passed PR demonstrates sound SOLID adherence by consolidating duplicated auth config logic (DRY principle), maintaining consistent patterns for feature extensions, and avoiding unnecessary complexity.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-instagram-connector

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Modifies authorization logic and return shapes in validateAuthorizeConnectorRequest.ts; security-related changes and new feature integrations require human review.

Architecture diagram
sequenceDiagram
    participant Client as Artist UI
    participant API as Connector Service
    participant Env as Environment (Env Vars)
    participant DB as Database (Access Control)

    Note over Client,DB: Discovery Flow
    Client->>API: GET /api/connectors
    API->>API: Filter SUPPORTED_TOOLKITS
    Note right of API: NEW: includes "instagram"
    API-->>Client: Return allowed connectors list

    Note over Client,DB: Authorization Flow (POST /api/connectors/authorize)
    Client->>API: Request authorization (connector, account_id?)
    
    Note over API,Env: NEW: Custom OAuth Config Resolution
    alt connector is "instagram"
        API->>Env: Read COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID
        Env-->>API: Config ID
    else connector is "tiktok"
        API->>Env: Read COMPOSIO_TIKTOK_AUTH_CONFIG_ID
        Env-->>API: Config ID
    end

    Note over API: CHANGED: authConfigs built before account check
    
    alt account_id provided
        API->>DB: checkAccountAccess(session_user, target_account)
        alt Authorized
            DB-->>API: Access Granted
            API-->>Client: Return { account_id, connector, authConfigs }
        else Unauthorized
            DB-->>API: Access Denied
            API-->>Client: 403 Forbidden
        end
    else no account_id provided
        Note right of API: CHANGED: Now returns authConfigs in this branch too
        API-->>Client: Return { session_accountId, connector, authConfigs }
    end
Loading

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/composio/connectors/validateAuthorizeConnectorRequest.ts (1)

53-62: Consider replacing per-connector if blocks with a mapping helper.

This branch pattern will keep expanding as new connectors are added. A small resolver utility would reduce duplication and help keep this validator slimmer.

♻️ Proposed refactor
+const CONNECTOR_AUTH_CONFIG_ENV: Record<string, string | undefined> = {
+  tiktok: process.env.COMPOSIO_TIKTOK_AUTH_CONFIG_ID,
+  instagram: process.env.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID,
+};
+
+function resolveConnectorAuthConfigs(
+  connector: string,
+): Record<string, string> | undefined {
+  const authConfigId = CONNECTOR_AUTH_CONFIG_ENV[connector];
+  return authConfigId ? { [connector]: authConfigId } : undefined;
+}
+
 export async function validateAuthorizeConnectorRequest(
   request: NextRequest,
 ): Promise<NextResponse | AuthorizeConnectorParams> {
@@
-  // Build auth configs for custom OAuth
-  const authConfigs: Record<string, string> = {};
-  if (connector === "tiktok" && process.env.COMPOSIO_TIKTOK_AUTH_CONFIG_ID) {
-    authConfigs.tiktok = process.env.COMPOSIO_TIKTOK_AUTH_CONFIG_ID;
-  }
-  if (connector === "instagram" && process.env.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID) {
-    authConfigs.instagram = process.env.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID;
-  }
-  const resolvedAuthConfigs = Object.keys(authConfigs).length > 0 ? authConfigs : undefined;
+  const resolvedAuthConfigs = resolveConnectorAuthConfigs(connector);

As per coding guidelines: lib/**/*.ts: “DRY: Consolidate similar logic into shared utilities” and “Keep functions under 50 lines”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/composio/connectors/validateAuthorizeConnectorRequest.ts` around lines 53
- 62, The per-connector if blocks building authConfigs should be replaced by a
small resolver: create a map (e.g. AUTH_CONFIG_ENV_MAP) from connector key to
the corresponding env var name (or a helper function getAuthConfigId(connector))
and use that to look up process.env once, adding authConfigs[connector] only
when a value exists; then set resolvedAuthConfigs as before. Move the map/helper
into a shared util (or the same module if private) to keep
validateAuthorizeConnectorRequest.ts slim and follow the DRY rule, referencing
the existing variables connector, authConfigs and resolvedAuthConfigs in your
changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/composio/connectors/validateAuthorizeConnectorRequest.ts`:
- Around line 53-62: The per-connector if blocks building authConfigs should be
replaced by a small resolver: create a map (e.g. AUTH_CONFIG_ENV_MAP) from
connector key to the corresponding env var name (or a helper function
getAuthConfigId(connector)) and use that to look up process.env once, adding
authConfigs[connector] only when a value exists; then set resolvedAuthConfigs as
before. Move the map/helper into a shared util (or the same module if private)
to keep validateAuthorizeConnectorRequest.ts slim and follow the DRY rule,
referencing the existing variables connector, authConfigs and
resolvedAuthConfigs in your changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 979a00e0-5113-4527-a7db-d10dc5ace2a1

📥 Commits

Reviewing files that changed from the base of the PR and between e5d1265 and f365475.

⛔ Files ignored due to path filters (2)
  • lib/composio/connectors/__tests__/getConnectors.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/composio/connectors/__tests__/isAllowedArtistConnector.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (3)
  • lib/composio/connectors/getConnectors.ts
  • lib/composio/connectors/isAllowedArtistConnector.ts
  • lib/composio/connectors/validateAuthorizeConnectorRequest.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Requires human review: Modifies core business logic and authentication configuration handling in the connector authorization path.

@sweetmantech

Copy link
Copy Markdown
Contributor

Manual Testing Results (Preview Deployment)

Preview URL: recoup-api-git-feature-add-instagram-cfe5c1-recoupable-ad724970.vercel.app
Account: 9105f630-8e9f-4908-a2c4-3f68a6454c78

GET /api/connectors

  • Instagram appears in connector list
  • TikTok still appears (regression check)
  • All 5 connectors returned (googlesheets, googledrive, googledocs, instagram, tiktok)

POST /api/connectors (Instagram)

  • Returns OAuth redirect URL successfully
  • Works with account_id override
  • Works without account_id (authenticated account)

POST /api/connectors (TikTok regression)

  • Returns OAuth redirect URL successfully
  • Works with account_id override
  • No regression from authConfigs refactor

@sweetmantech sweetmantech merged commit f84b25e into test Apr 6, 2026
5 of 6 checks passed
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.

2 participants