Next.js Discord

Discord Forum

Google authenticate() can't find my keyfilePath

Unanswered
Knopper gall posted this in #help-forum
Open in Discord
Knopper gallOP
I'm having trouble figuring out what's wrong. The CREDENTIALS_PATH points to the correct location of the credentials.json file, and I can read its contents without issue. However, when I attempt to pass it to keyfilePath, I get the following error: Error: Cannot find module 'D:\path\to\my\credentials.json'. Any help would be greatly appreciated. Thank you!
const CREDENTIALS_PATH = path.join(process.cwd(), "credentials.json");
async function authorize() {
  let client = await loadSavedCredentialsIfExist();
  if (client) {
    return client;
  }
  client = await authenticate({
    scopes: SCOPES,
    keyfilePath: CREDENTIALS_PATH,  // Error!!
  });
  if (client.credentials) {
    await saveCredentials(client);
  }
  return client;
}

0 Replies