停止自行建立 OAuth 流程,改用 WorkOS Pipes
🛑 Stop Building Custom OAuth Flows. Do This Instead.
WorkOS Pipes 以 API 和可嵌入式元件處理第三方整合,讓應用程式毋須自行建立 OAuth 流程。用戶可連接外部服務,應用程式透過 Pipes API 取得有效存取 token;WorkOS 會安全儲存憑證並自動更新過期 token,支援超過 100 個服務供應商。
The AI boom has exposed the biggest bottleneck in modern software engineering: Integration plumbing.
If you are building an AI agent, a developer tool, or a productivity app in 2026, your application is useless if it cannot access your users' data. Your users expect your app to seamlessly connect to their Slack channels, GitHub pull requests, Google Drive files, and Salesforce CRM.
But to actually build these connections, you have to run the dreaded OAuth gauntlet. You have to register an app with every single provider, build the OAuth flow, manage secure token storage, write logic for token refreshes, and handle the inevitable edge cases when tokens expire. Multiply that by 10 different providers, and you have just spent weeks building infrastructure that doesn't actually differentiate your core product.
Enter WorkOS Pipes, the tool that is officially killing the custom OAuth flow.
🔌 What is WorkOS Pipes?
WorkOS Pipes is a new API and embeddable widget that handles the entire lifecycle of third-party integrations for you. It is designed to let you connect your application to external data sources without forcing you to build and manage the underlying authorization infrastructure yourself.
Instead of dealing with tokens directly, you drop the Pipes widget into your app, let users connect their accounts with a single click, and then make one API call to WorkOS to get a fresh, valid access token whenever you need it.
💻 How it Works (The Code)
The integration experience is brilliantly simple and divided into two parts:
1. The Frontend Widget
Pipes provides a pre-built, embeddable UI component (built with Radix Themes and TanStack Query) that displays a list of available integrations. Your users simply check a box to connect their Google Workspace, GitHub, or Notion. No complex setup is required on their end, and the OAuth handshake happens entirely behind the scenes.
2. The Backend API Call
When your app actually needs to fetch data from the connected service, you don't query your own database for a stored token or write refresh logic. You simply ask the Pipes API for a token, and it guarantees you get a fresh one.
Here is what it looks like in practice:
// 1. Get a fresh, guaranteed-valid access token from Pipes
const token = await workos.pipes.getAccessToken({
userId: user.id,
provider: 'github'
});
// 2. Pass it directly to the provider's official SDK
const github = new GitHubClient(token);
const pullRequests = await github.getPullRequests();
That’s it. WorkOS handles securely storing the credentials, automatically refreshing expired tokens, managing the exact scopes you requested, and surfacing errors if re-authorization is ever needed.
🤖 Why This is Massive for AI Agents
This architecture is an absolute game-changer for AI applications. AI assistants require immense amounts of context from multiple sources to be useful. If you are building an AI scheduler, it needs access to Gmail and Google Calendar. If you are building an autonomous coding platform, it needs access to code repositories and task management tools.
By decoupling the integration flow from your core authentication (like Okta or Auth0), Pipes allows users to independently authorize specific data silos for your AI to access.
Pipes supports a massive list of over 100 providers, including GitHub, Google, Slack, Salesforce, Asana, Dropbox, HubSpot, Intercom, and Sentry.
If you are tired of spending your engineering cycles on token management instead of shipping actual features, it is time to delete your custom OAuth code.
Have you ever had to build a complex multi-provider OAuth system? Let's discuss the pain in the comments below! 👇
來源:DEV Community · dev.to
