Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import {
import fs from "fs";
import { google, tasks_v1 } from "googleapis";
import path from "path";
import { fileURLToPath } from "url";
import { TaskActions, TaskResources } from "./Tasks.js";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const tasks = google.tasks("v1");

const server = new Server(
Expand Down Expand Up @@ -259,17 +262,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
throw new Error("Tool not found");
});

const credentialsPath = path.join(
path.dirname(new URL(import.meta.url).pathname),
"../.gtasks-server-credentials.json",
);
const credentialsPath =
process.env.GOOGLE_TASKS_CREDENTIALS_PATH ||
path.join(__dirname, "../.gtasks-server-credentials.json");

async function authenticateAndSaveCredentials() {
console.log("Launching auth flow…");
const p = path.join(
path.dirname(new URL(import.meta.url).pathname),
"../gcp-oauth.keys.json",
);
const p =
process.env.GOOGLE_OAUTH_KEYS_PATH ||
path.join(__dirname, "../gcp-oauth.keys.json");

console.log(p);
const auth = await authenticate({
Expand Down