Skip to content

Conversation

@Shubhamxshah
Copy link

Summary

Adds Pinterest integration to enable creating pins on Pinterest boards directly from workflows. The integration includes OAuth authentication, dynamic board selection from authenticated accounts, and support for posting images with titles, descriptions, links, and alt text.

Changes:

  • Added Pinterest OAuth provider with required scopes (boards:read, boards:write, pins:read, pins:write)
  • Created Pinterest block with fields for board selection, title, description, image URL, link, and alt text
  • Implemented pinterest_create_pin and pinterest_list_boards tools
  • Added dynamic board selector that fetches boards from authenticated Pinterest account
  • Created API route /api/tools/pinterest/boards for board selection

Type of Change

  • New feature

Testing

Manual Testing Performed:

  • Pinterest OAuth connection flow
  • Dynamic board selection after authentication
  • Pin creation with all supported fields (title, description, media_url, link, alt_text)
  • Board list retrieval via API endpoint

What reviewers should focus on:

  • To test you'd need a approved pinterest production keys (takes 2 days to approve), i can send this to save time.
  • Pinterest OAuth flow and token handling (apps/sim/lib/auth/auth.ts:1-72, apps/sim/lib/oauth/oauth.ts)
  • Board selector implementation and dependency on credential (apps/sim/blocks/blocks/pinterest.ts:27-34)
  • Pin creation tool parameters and validation (apps/sim/tools/pinterest/create_pin.ts)
  • API route for fetching boards (apps/sim/app/api/tools/pinterest/boards/route.ts)
  • Error handling for Pinterest API calls

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the ./CONTRIBUTING.md#contributor-license-agreement-cla

Screenshots/Videos

image Screenshot from 2025-12-29 20-55-48 Screenshot from 2025-12-29 20-55-40

icecrasher321 and others added 12 commits December 18, 2025 16:23
…dioai#2481)

The realtime service network policy was missing the custom egress rules section
that allows configuration of additional egress rules via values.yaml. This caused
the realtime pods to be unable to connect to external databases (e.g., PostgreSQL
on port 5432) when using external database configurations.

The app network policy already had this section, but the realtime network policy
was missing it, creating an inconsistency and preventing the realtime service
from accessing external databases configured via networkPolicy.egress values.

This fix adds the same custom egress rules template section to the realtime
network policy, matching the app network policy behavior and allowing users to
configure database connectivity via values.yaml.
@vercel
Copy link

vercel bot commented Dec 29, 2025

@Shubhamxshah is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

@Shubhamxshah
Copy link
Author

@waleedlatif1 @icecrasher321 @emir-karabeg please review this

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile Summary

This PR adds a complete Pinterest integration enabling users to create pins on their Pinterest boards directly from workflows. The implementation follows established OAuth patterns in the codebase with proper token refresh support, board selection via dynamic selectors, and comprehensive error handling.

Key Changes:

  • OAuth provider configuration with boards:read, boards:write, pins:read, pins:write scopes
  • Pinterest block with dynamic board selector dependent on credential
  • Tools for creating pins (pinterest_create_pin) and listing boards (pinterest_list_boards)
  • API endpoint /api/tools/pinterest/boards for board selection with proper authorization
  • Board selector integrated into the selector registry and resolution system

Implementation Quality:

  • OAuth implementation includes fallback user info handling when Pinterest API calls fail
  • Token refresh properly configured with supportsRefreshTokenRotation: true
  • Error handling implemented at all layers (OAuth, tools, API routes)
  • Dynamic board selector properly depends on credential selection
  • All Pinterest API calls use v5 endpoints
  • Network policy updated to support custom egress rules

Confidence Score: 5/5

  • This PR is safe to merge - clean implementation following existing patterns
  • The implementation is thorough and follows established patterns consistently. OAuth setup mirrors other providers (Spotify, LinkedIn), error handling is comprehensive, and the dynamic selector integration is properly configured. No security issues, logic errors, or architectural concerns identified.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/auth/auth.ts added Pinterest OAuth provider with fallback user info handling for failed API calls
apps/sim/lib/oauth/oauth.ts registered Pinterest OAuth configuration with correct scopes and token refresh support
apps/sim/blocks/blocks/pinterest.ts created Pinterest block with board selector and pin creation fields
apps/sim/tools/pinterest/create_pin.ts implemented pin creation tool with proper error handling and optional fields
apps/sim/app/api/tools/pinterest/boards/route.ts created API endpoint for board selection with proper auth and token refresh
apps/sim/hooks/selectors/registry.ts registered pinterest.boards selector with proper data fetching and mapping

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as Workflow UI
    participant Auth as OAuth Service
    participant Pinterest as Pinterest API
    participant DB as Database
    participant Selector as Board Selector
    participant Tool as Create Pin Tool

    User->>UI: Configure Pinterest block
    UI->>Auth: Start Pinterest OAuth
    Auth->>Pinterest: OAuth handshake
    Pinterest->>Auth: OAuth complete
    Auth->>DB: Store OAuth info
    Auth->>UI: Connected successfully
    
    User->>UI: Open board selector
    UI->>Selector: Request boards (credentialId, workflowId)
    Selector->>Auth: Check access rights
    Auth->>Selector: Approved
    Selector->>Auth: Request API access
    Auth->>Pinterest: Verify and update
    Pinterest->>Auth: Ready for use
    Selector->>Pinterest: GET /v5/boards
    Pinterest->>Selector: List of boards
    Selector->>UI: Show boards in dropdown
    
    User->>UI: Create pin with details
    UI->>Tool: pinterest_create_pin(board_id, title, media_url, etc)
    Tool->>Auth: Request API access
    Auth->>Tool: Ready for API call
    Tool->>Pinterest: POST /v5/pins with data
    Pinterest->>Tool: Pin created
    Tool->>UI: Return pin_id, pin_url, success
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. apps/sim/lib/oauth/oauth.ts, line 1084-1086 (link)

    logic: Pinterest provider missing from getProviderAuthConfig function

18 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator

@Shubhamxshah please rebase and acknowledge the comments

Added Pinterest provider to getProviderAuthConfig() to enable automatic
token refresh when access tokens expire. Without this, users would
experience authentication failures after tokens expire.

Configuration:
- Token endpoint: https://api.pinterest.com/v5/oauth/token
- Uses Basic Authentication (as per Pinterest OAuth spec)
- Supports refresh token rotation

This prevents authentication failures and ensures continuous Pinterest
integration functionality.
@Shubhamxshah
Copy link
Author

@waleedlatif1 thanks for pointing out, i've fixed them.

@waleedlatif1
Copy link
Collaborator

@greptile

@vercel
Copy link

vercel bot commented Dec 30, 2025

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

Project Deployment Review Updated (UTC)
docs Error Error Dec 30, 2025 7:20am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (3)

  1. apps/sim/lib/auth/auth.ts, line 1789-1797 (link)

    logic: Date.now() generates a different ID each time, creating duplicate accounts on every failed auth attempt. Use a consistent identifier like the access token hash instead.

  2. apps/sim/lib/auth/auth.ts, line 1814-1822 (link)

    logic: Same issue: Date.now() creates a new user ID each time, causing duplicate accounts.

  3. apps/sim/lib/auth/auth.ts, line 1804 (link)

    logic: Date.now() fallback creates unstable user IDs. Since profile.username and profile.id should always exist in successful responses, this fallback indicates a data issue that should be logged differently.

18 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@Shubhamxshah
Copy link
Author

@greptile

@Shubhamxshah
Copy link
Author

@waleedlatif1 please review.

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.

4 participants