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

Function resolveOAuthMessage

apps/sim/hooks/use-oauth-return.ts:19–40  ·  view source on GitHub ↗
(ctx: OAuthReturnContext)

Source from the content-addressed store, hash-verified

17const CONTEXT_MAX_AGE_MS = 15 * 60 * 1000
18
19async function resolveOAuthMessage(ctx: OAuthReturnContext): Promise<string> {
20 if (ctx.reconnect) {
21 return `"${ctx.displayName}" reconnected successfully.`
22 }
23
24 try {
25 const data = await requestJson(listWorkspaceCredentialsContract, {
26 query: { workspaceId: ctx.workspaceId, type: 'oauth' },
27 })
28 const oauthCredentials = data.credentials ?? []
29
30 const forProvider = oauthCredentials.filter((c) => c.providerId === ctx.providerId)
31 if (forProvider.length > ctx.preCount) {
32 return `"${ctx.displayName}" credential connected successfully.`
33 }
34
35 const existing = forProvider[0]
36 return `This account is already connected as "${existing?.displayName || ctx.displayName}".`
37 } catch {
38 return `"${ctx.displayName}" credential connected successfully.`
39 }
40}
41
42function dispatchCredentialUpdate(ctx: OAuthReturnContext) {
43 window.dispatchEvent(

Callers 3

useOAuthReturnRouterFunction · 0.85

Calls 1

requestJsonFunction · 0.90

Tested by

no test coverage detected