opencode-gemini-auth 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/package.json +1 -1
- package/src/plugin/request.ts +3 -2
package/README.md
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
# Gemini OAuth Plugin for Opencode
|
|
2
2
|
|
|
3
|
-
Authenticate the Opencode CLI with your Google account so you can use your
|
|
3
|
+
Authenticate the Opencode CLI with your Google account so you can use your
|
|
4
|
+
existing Gemini plan and its included quota instead of API billing.
|
|
4
5
|
|
|
5
6
|
## Setup
|
|
6
7
|
|
|
7
8
|
1. Add the plugin to your [Opencode config](https://opencode.ai/docs/config/):
|
|
9
|
+
|
|
8
10
|
```json
|
|
9
11
|
{
|
|
10
12
|
"$schema": "https://opencode.ai/config.json",
|
|
11
13
|
"plugin": ["opencode-gemini-auth"]
|
|
12
14
|
}
|
|
13
15
|
```
|
|
16
|
+
|
|
14
17
|
2. Run `opencode auth login`.
|
|
15
18
|
3. Choose the Google provider and select **OAuth with Google (Gemini CLI)**.
|
|
16
19
|
|
|
17
|
-
The plugin spins up a local callback listener, so after approving in the
|
|
20
|
+
The plugin spins up a local callback listener, so after approving in the
|
|
21
|
+
browser you'll land on an "Authentication complete" page with no URL
|
|
22
|
+
copy/paste required. If that port is already taken, the CLI automatically
|
|
23
|
+
falls back to the classic copy/paste flow and explains what to do.
|
|
24
|
+
|
|
25
|
+
## Updating
|
|
26
|
+
|
|
27
|
+
> [!WARNING]
|
|
28
|
+
> OpenCode does NOT auto-update plugins
|
|
29
|
+
|
|
30
|
+
To get the latest version:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
(cd ~ && sed -i.bak '/"opencode-gemini-auth"/d' .cache/opencode/package.json && \
|
|
34
|
+
rm -rf .cache/opencode/node_modules/opencode-gemini-auth && \
|
|
35
|
+
echo "Plugin update script finished successfully.")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
opencode # Reinstalls latest
|
|
40
|
+
```
|
package/package.json
CHANGED
package/src/plugin/request.ts
CHANGED
|
@@ -39,8 +39,6 @@ export function prepareGeminiRequest(
|
|
|
39
39
|
): { request: RequestInfo; init: RequestInit; streaming: boolean } {
|
|
40
40
|
const baseInit: RequestInit = { ...init };
|
|
41
41
|
const headers = new Headers(init?.headers ?? {});
|
|
42
|
-
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
43
|
-
headers.delete("x-api-key");
|
|
44
42
|
|
|
45
43
|
if (!isGenerativeLanguageRequest(input)) {
|
|
46
44
|
return {
|
|
@@ -50,6 +48,9 @@ export function prepareGeminiRequest(
|
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
50
|
|
|
51
|
+
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
52
|
+
headers.delete("x-api-key");
|
|
53
|
+
|
|
53
54
|
const match = input.match(/\/models\/([^:]+):(\w+)/);
|
|
54
55
|
if (!match) {
|
|
55
56
|
return {
|