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

Function authorize

crates/opencode-plugin/builtin/copilot-auth.ts:26–55  ·  view source on GitHub ↗
(method: { label?: string }, inputs?: Record<string, string>)

Source from the content-addressed store, hash-verified

24 },
25 ],
26 async authorize(method: { label?: string }, inputs?: Record<string, string>) {
27 const enterprise = (method?.label ?? "").toLowerCase().includes("enterprise");
28 const enterpriseUrl = inputs?.enterpriseUrl ? normalizeDomain(inputs.enterpriseUrl) : undefined;
29 return {
30 method: "code",
31 instructions: enterprise
32 ? "Paste your GitHub Enterprise Copilot token/code."
33 : "Paste your GitHub Copilot token/code.",
34 callback: async (code?: string) => {
35 const value = code?.trim();
36 if (!value) return { type: "failed" };
37 if (enterprise) {
38 return {
39 type: "success",
40 provider: "github-copilot-enterprise",
41 enterpriseUrl: enterpriseUrl,
42 access: value,
43 refresh: value,
44 expires: 0,
45 };
46 }
47 return {
48 type: "success",
49 access: value,
50 refresh: value,
51 expires: 0,
52 };
53 },
54 };
55 },
56 async loader() {
57 const key =
58 process.env.GITHUB_COPILOT_API_KEY?.trim() ||

Callers

nothing calls this directly

Calls 1

normalizeDomainFunction · 0.85

Tested by

no test coverage detected