MCPcopy Index your code
hub / github.com/21st-dev/1code / startAuthFlow

Method startAuthFlow

src/main/auth-manager.ts:209–223  ·  view source on GitHub ↗

* Start auth flow by opening browser

(mainWindow: BrowserWindow | null)

Source from the content-addressed store, hash-verified

207 * Start auth flow by opening browser
208 */
209 startAuthFlow(mainWindow: BrowserWindow | null): void {
210 const { shell } = require("electron")
211
212 let authUrl = `${this.getApiUrl()}/auth/desktop?auto=true`
213
214 // In dev mode, use localhost callback (we run HTTP server on AUTH_SERVER_PORT)
215 // Also pass the protocol so web knows which deep link to use as fallback
216 if (this.isDev) {
217 authUrl += `&callback=${encodeURIComponent(`http://localhost:${AUTH_SERVER_PORT}/auth/callback`)}`
218 // Pass dev protocol so production web can use correct deep link if callback fails
219 authUrl += `&protocol=twentyfirst-agents-dev`
220 }
221
222 shell.openExternal(authUrl)
223 }
224
225 /**
226 * Update user profile on server and locally

Callers

nothing calls this directly

Calls 1

getApiUrlMethod · 0.95

Tested by

no test coverage detected