I’m trying to get my head around something.
We have a web app that auth’s with Pipedrive and users go off and do their thing. Our app handles refresh tokens and it all works fine.
I want to add a function where an action is performed on a schedule without user interaction and I’m struggling to work out how to handle auth. I want auth to work like it does in Zapier for example. User auth’s the app and then everything happens in the background on our server. But how to handle tokens in a server environment?
Hi @Kurt_Jones
I assume that once a user installs your app, you save access/refresh tokens that are connected to a user ID. Table structure might look like this
id | company_id | user_id | access_token | refresh_token | expires_at
where
id - is a unique ID in your system which you can use to find/connect Pipedrive user in your system
company_id - Pipedrive’s company ID
user_id - Pipedrive’s user ID
company_id + user_id is a unique index in this table
When the cron starts, most likely it operates with some user’s data, which you could use to find a connected Pipedrive user.
Once a connected Pipedrive user is found, you can make requests in backgound to Pipedrive API using access_token
and if’s already expired, refresh it, save new tokens and make an API call. And from what I understood you should already have this logic.
Hope it helps.