MCPcopy Index your code
hub / github.com/simstudioai/sim / executeOAuthGetAuthLink

Function executeOAuthGetAuthLink

apps/sim/lib/copilot/tools/handlers/oauth.ts:7–49  ·  view source on GitHub ↗
(
  rawParams: Record<string, unknown>,
  context: ExecutionContext
)

Source from the content-addressed store, hash-verified

5import { getAllOAuthServices } from '@/lib/oauth/utils'
6
7export async function executeOAuthGetAuthLink(
8 rawParams: Record<string, unknown>,
9 context: ExecutionContext
10): Promise<ToolCallResult> {
11 const providerName = String(rawParams.providerName || rawParams.provider_name || '')
12 const baseUrl = getBaseUrl()
13 try {
14 if (!context.workspaceId || !context.userId) {
15 throw new Error('workspaceId and userId are required to generate an OAuth link')
16 }
17 await ensureWorkspaceAccess(context.workspaceId, context.userId, 'write')
18 const result = await generateOAuthLink(
19 context.workspaceId,
20 context.workflowId,
21 context.chatId,
22 providerName,
23 baseUrl
24 )
25 return {
26 success: true,
27 output: {
28 message: `Authorization URL generated for ${result.serviceName}.`,
29 oauth_url: result.url,
30 instructions: `Open this URL in your browser to connect ${result.serviceName}: ${result.url}`,
31 provider: result.serviceName,
32 providerId: result.providerId,
33 },
34 }
35 } catch (err) {
36 const workspaceUrl = context.workspaceId
37 ? `${baseUrl}/workspace/${context.workspaceId}`
38 : `${baseUrl}/workspace`
39 return {
40 success: false,
41 error: toError(err).message,
42 output: {
43 message: `Could not generate a direct OAuth link for ${providerName}. Connect manually from the workspace.`,
44 oauth_url: workspaceUrl,
45 error: toError(err).message,
46 },
47 }
48 }
49}
50
51export async function executeOAuthRequestAccess(
52 rawParams: Record<string, unknown>,

Callers

nothing calls this directly

Calls 4

getBaseUrlFunction · 0.90
ensureWorkspaceAccessFunction · 0.90
toErrorFunction · 0.90
generateOAuthLinkFunction · 0.85

Tested by

no test coverage detected