Skip to main content

Better Oauth2.0 workflow for Pipedrive CRM with Supabase

Workflow preview

Workflow preview
100%
Better Oauth2.0 workflow for Pipedrive CRM with Supabase preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow provides an OAuth 2.0 auth token refresh process for better control. Developers can utilize it as an alternative to n8n's built in OAuth flow to achieve improved control and visibilit...

Best for

  • Engineering automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stopanderror, n8n-nodes-base.stickynote, n8n-nodes-base.supabase, n8n-nodes-base.httprequest, n8n-nodes-base.if, n8n-nodes-base.respondtowebhook, n8n-nodes-base.code, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Priya Jain.

Original n8n.io source

1.1 Workflow description

Title
Better Oauth2.0 workflow for Pipedrive CRM with Supabase
Workflow name
Better Oauth2.0 workflow for Pipedrive CRM with Supabase

This workflow provides an OAuth 2.0 auth token refresh process for better control. Developers can utilize it as an alternative to n8n's built-in OAuth flow to achieve improved control and visibility. In this template, I've used Pipedrive API, but users can apply it with any app that requires the authorization_code for token access.

This resolves the issue of manually refreshing the OAuth 2.0 token when it expires, or when n8n's native OAuth stops working.

What you need to replicate this

  1. Your database with a pre-existing table for storing authentication tokens and associated information. I'm using Supabase in this example, but you can also employ a self-hosted MySQL.

Here's a quick video on setting up the Supabase table.

  1. Create a client app for your chosen application that you want to access via the API.

  2. After duplicating the template:

a. Add credentials to your database and connect the DB nodes in all 3 workflows.

  1. Enable/Publish the first workflow, "1. Generate and Save Pipedrive tokens to Database."

  2. Open your client app and follow the Pipedrive instructions to authenticate.

Click on Install and test.

This will save your initial refresh token and access token to the database.

  1. Please watch the YouTube video for a detailed demonstration of the workflow:

How it operates

Workflow 1. Create a workflow to capture the authorization_code, generate the access_token, and refresh the token, and then save the token to the database.

Workflow 2. Develop your primary workflow to fetch or post data to/from your application. Observe the logic to include an if condition when an error occurs with an invalid token. This triggers the third workflow to refresh the token.

Workflow 3. This workflow will handle the token refresh. Remember to send the unique ID to the webhook to fetch the necessary tokens from your table.

Detailed demonstration of the workflow: https://youtu.be/6nXi_yverss

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Stop and Error

Type / Role
n8n-nodes-base.stopAndError - stopAndError
Config choices
Version 1

Block 2 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Insert

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 7 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Get Pipedrive Token

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 10 - Get contact from Pipedrive

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4

Block 11 - Access Token Invalid

Type / Role
n8n-nodes-base.if - if
Config choices
Version 1

Block 12 - Success

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 13 - Refresh Access Token

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 14 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - convert clientId and secret to base64

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Generate Refresh Token from authcode

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4

Block 19 - Look for the related record in Supabase

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 20 - IF rec not found

Type / Role
n8n-nodes-base.if - if
Config choices
Version 1

Block 21 - Update tokns in the record

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 22 - Supabase- look for the record

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 23 - combine client id and secret

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 24 - Get Pipedrive acess token

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Showing the first 24 of 29 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Better Oauth2.0 workflow for Pipedrive CRM with Supabase
Complexity advanced
Nodes 29
Categories Engineering
Author Priya Jain
Published 06 Jul 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2319/2319.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Better Oauth2.0 workflow for Pipedrive CRM with Supabase do?

This workflow provides an OAuth 2.0 auth token refresh process for better control. Developers can utilize it as an alternative to n8n's built in OAuth flow to achieve improved control and visibilit...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.