MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / CodexAuthPlugin

Function CodexAuthPlugin

crates/opencode-plugin/builtin/codex-auth.ts:9–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7 */
8
9export default async function CodexAuthPlugin() {
10 return {
11 auth: {
12 provider: "openai",
13 methods: [
14 {
15 type: "oauth",
16 label: "ChatGPT/Codex OAuth (paste code)",
17 },
18 ],
19 async authorize() {
20 return {
21 method: "code",
22 instructions:
23 "Open ChatGPT/Codex authorization and paste the returned code/token here.",
24 callback: async (code?: string) => {
25 const value = code?.trim();
26 if (!value) return { type: "failed" };
27 return {
28 type: "success",
29 access: value,
30 refresh: value,
31 expires: Date.now() + 3600 * 1000,
32 };
33 },
34 };
35 },
36 async loader() {
37 const key = process.env.OPENAI_API_KEY?.trim();
38 if (!key) return {};
39 return {
40 apiKey: key,
41 };
42 },
43 },
44 "chat.headers": async () => {
45 return {
46 originator: "opencode",
47 "x-title": "opencode",
48 };
49 },
50 };
51}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected