Published 2 months ago
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.
Here's a quick video on setting up the Supabase table.
Create a client app for your chosen application that you want to access via the API.
After duplicating the template:
a. Add credentials to your database and connect the DB nodes in all 3 workflows.
Enable/Publish the first workflow, "1. Generate and Save Pipedrive tokens to Database."
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.
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