* Refresh token for a source * * Returns the new access token, or null if refresh fails. * On success, credentials are automatically updated.
(source: LoadedSource)
| 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 |
nothing calls this directly
no test coverage detected