MCPcopy Index your code
hub / github.com/anomalyco/opencode / authorize

Function authorize

packages/opencode/src/plugin/snowflake-cortex.ts:463–497  ·  view source on GitHub ↗
(inputs = {})

Source from the content-addressed store, hash-verified

461 label: "Login with Snowflake (External Browser)",
462 prompts,
463 async authorize(inputs = {}) {
464 const account = normalizeAccount(inputs.account || "")
465 if (!account) throw new Error("Snowflake account is required")
466
467 await startOAuthServer()
468 const pkce = await generatePKCE()
469 const state = generateRandomString(64)
470 const role = (inputs.role || "").trim() || undefined
471 const url = buildAuthorizeUrl(account, role, state, pkce)
472 const callbackPromise = waitForOAuthCallback(account, pkce, state)
473 await open(url).catch(() => undefined)
474
475 return {
476 url,
477 instructions:
478 "Complete Snowflake sign-in in your browser. OpenCode will capture the OAuth callback and store the bearer token automatically.",
479 method: "auto" as const,
480 async callback() {
481 try {
482 const tokens = await callbackPromise
483 return {
484 type: "success" as const,
485 refresh: tokens.refresh_token!,
486 access: tokens.access_token,
487 expires: Date.now() + (tokens.expires_in ?? 600) * 1000,
488 accountId: account,
489 }
490 } catch {
491 return { type: "failed" as const }
492 } finally {
493 stopOAuthServer()
494 }
495 },
496 }
497 },
498 },
499 {
500 type: "api",

Callers

nothing calls this directly

Calls 7

normalizeAccountFunction · 0.85
startOAuthServerFunction · 0.70
generatePKCEFunction · 0.70
generateRandomStringFunction · 0.70
buildAuthorizeUrlFunction · 0.70
waitForOAuthCallbackFunction · 0.70
openFunction · 0.50

Tested by

no test coverage detected