just-bash-gdrive 0.1.0 → 0.1.1
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 +34 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,7 +76,32 @@ const { text } = await generateText({
|
|
|
76
76
|
|
|
77
77
|
### Getting an access token
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
The `accessToken` option accepts either a static string or an async function — use the async form for long-running agents so the token refreshes automatically.
|
|
80
|
+
|
|
81
|
+
**Option 1: [gogcli](https://github.com/steipete/gogcli) (recommended for quick setup)**
|
|
82
|
+
|
|
83
|
+
gogcli handles Google OAuth2 authentication and stores tokens locally. After running `gog auth login`, you can retrieve tokens programmatically:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Install gogcli
|
|
87
|
+
npm install -g gogcli
|
|
88
|
+
|
|
89
|
+
# Authenticate (opens browser)
|
|
90
|
+
gog auth login
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { execSync } from "child_process";
|
|
95
|
+
|
|
96
|
+
const fs = new GDriveFs({
|
|
97
|
+
accessToken: () => {
|
|
98
|
+
// gogcli outputs a fresh token to stdout
|
|
99
|
+
return execSync("gog auth token", { encoding: "utf8" }).trim();
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Option 2: googleapis (full OAuth2 flow)**
|
|
80
105
|
|
|
81
106
|
```ts
|
|
82
107
|
import { google } from "googleapis";
|
|
@@ -92,6 +117,14 @@ const fs = new GDriveFs({
|
|
|
92
117
|
});
|
|
93
118
|
```
|
|
94
119
|
|
|
120
|
+
**Option 3: Static token (scripts and testing)**
|
|
121
|
+
|
|
122
|
+
For short-lived scripts, pass a token directly. Get one via `gog auth token` or the [OAuth2 Playground](https://developers.google.com/oauthplayground).
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
const fs = new GDriveFs({ accessToken: "ya29.your_token_here" });
|
|
126
|
+
```
|
|
127
|
+
|
|
95
128
|
## Options
|
|
96
129
|
|
|
97
130
|
| Option | Type | Default | Description |
|