HTTP Request node
Webhook node
+5

Better Oauth2.0 workflow for Pipedrive CRM with Supabase

Published 2 months ago

Created by

processease
Priya Jain

Categories

Sales
Building Blocks

Template description

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

Share Template

Implement complex processes faster with n8n

red icon yellow icon red icon yellow icon