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

Function useOAuthReturnForKBConnectors

apps/sim/hooks/use-oauth-return.ts:133–147  ·  view source on GitHub ↗
(knowledgeBaseId: string)

Source from the content-addressed store, hash-verified

131 * Consumes the return context and shows a toast notification.
132 */
133export function useOAuthReturnForKBConnectors(knowledgeBaseId: string) {
134 useEffect(() => {
135 const ctx = readOAuthReturnContext()
136 if (!ctx || ctx.origin !== 'kb-connectors') return
137 if (ctx.knowledgeBaseId !== knowledgeBaseId) return
138 consumeOAuthReturnContext()
139 if (Date.now() - ctx.requestedAt > CONTEXT_MAX_AGE_MS) return
140
141 void (async () => {
142 const message = await resolveOAuthMessage(ctx)
143 toast.success(message)
144 dispatchCredentialUpdate(ctx)
145 })()
146 }, [knowledgeBaseId])
147}

Callers 1

KnowledgeBaseFunction · 0.90

Calls 4

readOAuthReturnContextFunction · 0.90
resolveOAuthMessageFunction · 0.85
dispatchCredentialUpdateFunction · 0.85

Tested by

no test coverage detected