Skip to content

Commit 8d54d44

Browse files
Merge pull request #552 from anishp/gdrive-path-fix
windows credential file path resolution fixes #301
2 parents c37ce47 + a24a33a commit 8d54d44

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/gdrive/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import fs from "fs";
1313
import { google } from "googleapis";
1414
import path from "path";
15+
import { fileURLToPath } from 'url';
1516

1617
const drive = google.drive("v3");
1718

@@ -176,15 +177,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
176177
});
177178

178179
const credentialsPath = process.env.GDRIVE_CREDENTIALS_PATH || path.join(
179-
path.dirname(new URL(import.meta.url).pathname),
180+
path.dirname(fileURLToPath(import.meta.url)),
180181
"../../../.gdrive-server-credentials.json",
181182
);
182183

183184
async function authenticateAndSaveCredentials() {
184185
console.log("Launching auth flow…");
185186
const auth = await authenticate({
186187
keyfilePath: process.env.GDRIVE_OAUTH_PATH || path.join(
187-
path.dirname(new URL(import.meta.url).pathname),
188+
path.dirname(fileURLToPath(import.meta.url)),
188189
"../../../gcp-oauth.keys.json",
189190
),
190191
scopes: ["https://www.googleapis.com/auth/drive.readonly"],

0 commit comments

Comments
 (0)