MCPcopy
hub / github.com/21st-dev/1code / refresh

Method refresh

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

* Refresh token for a source * * Returns the new access token, or null if refresh fails. * On success, credentials are automatically updated.

(source: LoadedSource)

Source from the content-addressed store, hash-verified

593 * On success, credentials are automatically updated.
594 */
595 async refresh(source: LoadedSource): Promise<string | null> {
596 const cred = await this.load(source);
597 if (!cred?.refreshToken) {
598 debug(`[SourceCredentialManager] No refresh token for ${source.config.slug}`);
599 return null;
600 }
601
602 // Google API refresh
603 if (source.config.provider === 'google') {
604 return this.refreshGoogle(source, cred);
605 }
606
607 // Slack API refresh
608 if (source.config.provider === 'slack') {
609 return this.refreshSlack(source, cred);
610 }
611
612 // Microsoft API refresh
613 if (source.config.provider === 'microsoft') {
614 return this.refreshMicrosoft(source, cred);
615 }
616
617 // MCP refresh
618 if (source.config.type === 'mcp' && source.config.mcp?.url) {
619 return this.refreshMcp(source, cred);
620 }
621
622 return null;
623 }
624
625 /**
626 * Refresh Google OAuth token

Callers

nothing calls this directly

Calls 5

loadMethod · 0.95
refreshGoogleMethod · 0.95
refreshSlackMethod · 0.95
refreshMicrosoftMethod · 0.95
refreshMcpMethod · 0.95

Tested by

no test coverage detected