I am trying to move from using the entire googleapis package in my firebase cloud function (nodejs) project to using only the sub packages I need.
This is what I have that works currently:
const {google} = require('googleapis');
const oAuth2Client = new google.auth.OAuth2(
CLIENT_ID,
CLIENT_SECRET,
REDIRECT_URI
);
oAuth2Client.setCredentials({ refresh_token: REFRESH_TOKEN });
// Do some stuff with oAuth2Client
This is what I am trying to do but not having success. I have run npm i @googleapis/oauth2.
I am getting
Error: Failed to load function definition from source: Failed to
generate manifest from function source: TypeError: OAuth2 is not a
constructor
const { OAuth2 } = require('@googleapis/oauth2');
const oAuth2Client = new OAuth2 (
CLIENT_ID,
CLIENT_SECRET,
REDIRECT_URI
);
oAuth2Client.setCredentials({ refresh_token: REFRESH_TOKEN });
// Do some stuff with oAuth2Client
I have also tried new OAuth2.auth.OAuth2( and new OAuth2.OAuth2( and get:
Error: Failed to load function definition from source: Failed to
generate manifest from function source: TypeError: Cannot read
properties of undefined (reading ‘auth’)