Keep your CRM calls running without manual token fixes. This workflow stores and refreshes OAuth tokens, then searches contacts by email on demand. It is great for teams that get leads from forms or apps and need reliable access to Pipedrive data.
Three webhooks drive the flow. One catches the OAuth code and saves both refresh and access tokens to Supabase. A second endpoint refreshes tokens using your client id and secret. The third endpoint receives a request with a person email, pulls the latest token from Supabase, calls the Pipedrive search API, and returns the result. If the access token is invalid, the logic refreshes it and tries again. The flow uses Supabase for secure storage, IF checks to detect token errors, and a loop that keeps the call stable.
To set this up you need a Pipedrive OAuth app and a Supabase project with a table for tokens. Expect fewer API failures, faster lead lookups, and less time spent fixing tokens. Use it to power web forms, chatbots, or internal tools that need quick CRM checks without downtime.