INNER CODE UNIT · TypeScript

refreshOAuthToken

Dicklesworthstone/pi_agent_rust · legacy_pi_mono_code/pi-mono/packages/ai/src/utils/oauth/index.ts:93

export async function refreshOAuthToken(
	providerId: OAuthProviderId,
	credentials: OAuthCredentials,
): Promise<OAuthCredentials> {
	const provider = getOAuthProvider(providerId);
	if (!provider) {
		throw new Error(`Unknown OAuth provider: ${providerId}`);
	}
	return provider.refreshToken(credentials);
}

/**
 * Get API key for a provider from OAuth credentials.
 * Automatically refreshes expired tokens.
 *
 * @returns API key string and updated credentials, or null if no credentials
 * @throws Error if refresh fails
 */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…