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

Method refreshMicrosoft

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

* Refresh Microsoft OAuth token

(
    source: LoadedSource,
    cred: StoredCredential
  )

Source from the content-addressed store, hash-verified

680 * Refresh Microsoft OAuth token
681 */
682 private async refreshMicrosoft(
683 source: LoadedSource,
684 cred: StoredCredential
685 ): Promise<string | null> {
686 try {
687 const result = await refreshMicrosoftToken(cred.refreshToken!);
688
689 // Update stored credentials (Microsoft may rotate refresh tokens)
690 await this.save(source, {
691 ...cred,
692 value: result.accessToken,
693 refreshToken: result.refreshToken || cred.refreshToken,
694 expiresAt: result.expiresAt,
695 });
696
697 debug(`[SourceCredentialManager] Refreshed Microsoft token for ${source.config.slug}`);
698 return result.accessToken;
699 } catch (error) {
700 const errorMsg = error instanceof Error ? error.message : String(error);
701 debug(`[SourceCredentialManager] Microsoft token refresh failed:`, error);
702 this.markSourceNeedsReauth(source, `Token refresh failed: ${errorMsg}`);
703 return null;
704 }
705 }
706
707 /**
708 * Refresh MCP OAuth token

Callers 1

refreshMethod · 0.95

Calls 2

saveMethod · 0.95
markSourceNeedsReauthMethod · 0.95

Tested by

no test coverage detected