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

Method authenticate

src/main/lib/credential-manager.ts:312–346  ·  view source on GitHub ↗

* Authenticate source via OAuth * * Handles both MCP OAuth and Gmail OAuth flows. * On success, credentials are automatically saved.

(
    source: LoadedSource,
    callbacks?: OAuthCallbacks
  )

Source from the content-addressed store, hash-verified

310 * On success, credentials are automatically saved.
311 */
312 async authenticate(
313 source: LoadedSource,
314 callbacks?: OAuthCallbacks
315 ): Promise<AuthResult> {
316 const defaultCallbacks: OAuthCallbacks = {
317 onStatus: (msg) => debug(`[SourceCredentialManager] ${msg}`),
318 onError: (err) => debug(`[SourceCredentialManager] Error: ${err}`),
319 };
320 const cb = callbacks || defaultCallbacks;
321
322 // Google APIs use Google OAuth
323 if (source.config.provider === 'google') {
324 return this.authenticateGoogle(source, cb);
325 }
326
327 // Slack APIs use Slack OAuth
328 if (source.config.provider === 'slack') {
329 return this.authenticateSlack(source, cb);
330 }
331
332 // Microsoft APIs use Microsoft OAuth
333 if (source.config.provider === 'microsoft') {
334 return this.authenticateMicrosoft(source, cb);
335 }
336
337 // MCP OAuth flow
338 if (source.config.type === 'mcp' && source.config.mcp?.authType === 'oauth') {
339 return this.authenticateMcp(source, cb);
340 }
341
342 return {
343 success: false,
344 error: `Source ${source.config.slug} does not use OAuth authentication`,
345 };
346 }
347
348 /**
349 * Authenticate MCP source via OAuth

Callers

nothing calls this directly

Calls 4

authenticateGoogleMethod · 0.95
authenticateSlackMethod · 0.95
authenticateMicrosoftMethod · 0.95
authenticateMcpMethod · 0.95

Tested by

no test coverage detected