mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-29 01:31:18 +00:00
refactor(auth): reuse oauth auth result helper
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { createHash, randomBytes } from "node:crypto";
|
import { createHash, randomBytes } from "node:crypto";
|
||||||
import { createServer } from "node:http";
|
import { createServer } from "node:http";
|
||||||
import {
|
import {
|
||||||
|
buildOauthProviderAuthResult,
|
||||||
emptyPluginConfigSchema,
|
emptyPluginConfigSchema,
|
||||||
isWSL2Sync,
|
isWSL2Sync,
|
||||||
type OpenClawPluginApi,
|
type OpenClawPluginApi,
|
||||||
@@ -396,37 +397,19 @@ const antigravityPlugin = {
|
|||||||
progress: spin,
|
progress: spin,
|
||||||
});
|
});
|
||||||
|
|
||||||
const profileId = `google-antigravity:${result.email ?? "default"}`;
|
return buildOauthProviderAuthResult({
|
||||||
return {
|
providerId: "google-antigravity",
|
||||||
profiles: [
|
|
||||||
{
|
|
||||||
profileId,
|
|
||||||
credential: {
|
|
||||||
type: "oauth",
|
|
||||||
provider: "google-antigravity",
|
|
||||||
access: result.access,
|
|
||||||
refresh: result.refresh,
|
|
||||||
expires: result.expires,
|
|
||||||
email: result.email,
|
|
||||||
projectId: result.projectId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
configPatch: {
|
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
models: {
|
|
||||||
[DEFAULT_MODEL]: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultModel: DEFAULT_MODEL,
|
defaultModel: DEFAULT_MODEL,
|
||||||
|
access: result.access,
|
||||||
|
refresh: result.refresh,
|
||||||
|
expires: result.expires,
|
||||||
|
email: result.email,
|
||||||
|
credentialExtra: { projectId: result.projectId },
|
||||||
notes: [
|
notes: [
|
||||||
"Antigravity uses Google Cloud project quotas.",
|
"Antigravity uses Google Cloud project quotas.",
|
||||||
"Enable Gemini for Google Cloud on your project if requests fail.",
|
"Enable Gemini for Google Cloud on your project if requests fail.",
|
||||||
],
|
],
|
||||||
};
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
spin.stop("Antigravity OAuth failed");
|
spin.stop("Antigravity OAuth failed");
|
||||||
throw err;
|
throw err;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
buildOauthProviderAuthResult,
|
||||||
emptyPluginConfigSchema,
|
emptyPluginConfigSchema,
|
||||||
type OpenClawPluginApi,
|
type OpenClawPluginApi,
|
||||||
type ProviderAuthContext,
|
type ProviderAuthContext,
|
||||||
@@ -46,34 +47,16 @@ const geminiCliPlugin = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
spin.stop("Gemini CLI OAuth complete");
|
spin.stop("Gemini CLI OAuth complete");
|
||||||
const profileId = `google-gemini-cli:${result.email ?? "default"}`;
|
return buildOauthProviderAuthResult({
|
||||||
return {
|
providerId: PROVIDER_ID,
|
||||||
profiles: [
|
|
||||||
{
|
|
||||||
profileId,
|
|
||||||
credential: {
|
|
||||||
type: "oauth",
|
|
||||||
provider: PROVIDER_ID,
|
|
||||||
access: result.access,
|
|
||||||
refresh: result.refresh,
|
|
||||||
expires: result.expires,
|
|
||||||
email: result.email,
|
|
||||||
projectId: result.projectId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
configPatch: {
|
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
models: {
|
|
||||||
[DEFAULT_MODEL]: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultModel: DEFAULT_MODEL,
|
defaultModel: DEFAULT_MODEL,
|
||||||
|
access: result.access,
|
||||||
|
refresh: result.refresh,
|
||||||
|
expires: result.expires,
|
||||||
|
email: result.email,
|
||||||
|
credentialExtra: { projectId: result.projectId },
|
||||||
notes: ["If requests fail, set GOOGLE_CLOUD_PROJECT or GOOGLE_CLOUD_PROJECT_ID."],
|
notes: ["If requests fail, set GOOGLE_CLOUD_PROJECT or GOOGLE_CLOUD_PROJECT_ID."],
|
||||||
};
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
spin.stop("Gemini CLI OAuth failed");
|
spin.stop("Gemini CLI OAuth failed");
|
||||||
await ctx.prompter.note(
|
await ctx.prompter.note(
|
||||||
|
|||||||
Reference in New Issue
Block a user