mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
22 lines
573 B
TypeScript
22 lines
573 B
TypeScript
// Google plugin module implements gemini auth behavior.
|
|
import { parseGoogleOauthApiKey } from "./oauth-token-shared.js";
|
|
|
|
export function parseGeminiAuth(apiKey: string): { headers: Record<string, string> } {
|
|
const parsed = apiKey.startsWith("{") ? parseGoogleOauthApiKey(apiKey) : null;
|
|
if (parsed?.token) {
|
|
return {
|
|
headers: {
|
|
Authorization: `Bearer ${parsed.token}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
};
|
|
}
|
|
|
|
return {
|
|
headers: {
|
|
"x-goog-api-key": apiKey,
|
|
"Content-Type": "application/json",
|
|
},
|
|
};
|
|
}
|