This topic was automatically generated from Slack. You can find the original thread here.
I’m trying to create a flow where
• a user auths once per provider, say, Google Sheets, Zendesk, Salesforce
• for as long as they are connected, we will be able to proxy tool calls through their account
can we implement an auto-refresh flow with connect tokens (which “currently have a 4-hour expiry, and can only be used once.”)? or do you also provide a long-running auth solution?
Pipedream Connect tokens, as described, have a 4-hour expiry and are single-use only. This means they are designed for short-lived, one-time operations and cannot be used for long-running, persistent connections or for implementing an auto-refresh flow for ongoing proxying of tool calls through a user’s account. ### Long-Running Auth on Pipedream However, Pipedream’s managed OAuth integrations (like Google Sheets, Zendesk, Salesforce, etc.) are specifically built for long-running connections. When a user authenticates with one of these providers in Pipedream, Pipedream manages the OAuth access and refresh tokens for you: - Access tokens are automatically refreshed by Pipedream when they expire, as long as the refresh token is valid and the user hasn’t revoked access. - You can make API calls on behalf of the user at any time, as long as their account is connected in Pipedream. - You do not need to implement your own refresh logic for these managed OAuth apps. #### Example: Using Managed Auth in a Pipedream Component For Google, Zendesk, Salesforce, etc., you can use the app prop in your component, and Pipedream will handle token refresh for you: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, }, async run({ steps, $ }) { // Pipedream automatically refreshes tokens if needed return await axios($, { url: https://www.googleapis.com/oauth2/v1/userinfo, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, }); }, });
Pipedream’s managed OAuth integrations allow you to connect user accounts (like Google Sheets, Zendesk, Salesforce, etc.) and automatically handle token refreshes for you. You do not need to implement your own token refresh logic. Once a user connects their account via the Pipedream UI, you can make API calls on their behalf in your workflow steps, and Pipedream will ensure the access token is valid (refreshing it as needed). ### How Managed OAuth Works in Pipedream Components For each supported app, you add a prop of type "app" to your component. For example, for Google: import { axios } from "@pipedream/platform" export default defineComponent({ props: { google: { type: "app", app: "google", } }, async run({steps, $}) { return await axios($, { url: `https://www.googleapis.com/oauth2/v1/userinfo`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, }) }, }) - The this.google.$auth.oauth_access_token property is automatically managed and refreshed by Pipedream. - You can use similar patterns for Zendesk, Salesforce, and other OAuth apps. ### Where to Find More Information - Google integration docs - Zendesk integration docs Summary: You do not need to implement your own auto-refresh logic. Just use the managed OAuth props as shown above, and Pipedream will handle the rest. If you need more details on a specific app, let me know which one and I can provide the exact component example. If you have further questions or need more help, please visit Support - Pipedream.