MCPcopy
hub / github.com/simstudioai/sim / useOAuthReturnForWorkflow

Function useOAuthReturnForWorkflow

apps/sim/hooks/use-oauth-return.ts:113–127  ·  view source on GitHub ↗
(workflowId: string)

Source from the content-addressed store, hash-verified

111 * Consumes the return context and shows a workflow-scoped notification.
112 */
113export function useOAuthReturnForWorkflow(workflowId: string) {
114 useEffect(() => {
115 const ctx = readOAuthReturnContext()
116 if (!ctx || ctx.origin !== 'workflow') return
117 if (ctx.workflowId !== workflowId) return
118 consumeOAuthReturnContext()
119 if (Date.now() - ctx.requestedAt > CONTEXT_MAX_AGE_MS) return
120
121 void (async () => {
122 const message = await resolveOAuthMessage(ctx)
123 toast.success(message)
124 dispatchCredentialUpdate(ctx)
125 })()
126 }, [workflowId])
127}
128
129/**
130 * Post-OAuth handler for KB connectors pages.

Callers 1

workflow.tsxFile · 0.90

Calls 4

readOAuthReturnContextFunction · 0.90
resolveOAuthMessageFunction · 0.85
dispatchCredentialUpdateFunction · 0.85

Tested by

no test coverage detected