I'm currently working on a project where I need to access Google Sheets using the google-spreadsheet npm package. Due to restrictions, I'm based in China and using a VPN to access Google services. However, I'm encountering an issue where I'm getting the following error Error: Request to https://www.googleapis.com/oauth2/v4/token failed, reason:
Here's the relevant code snippet:
import { JWT } from "google-auth-library";
import { GoogleSpreadsheet} from "google-spreadsheet";
const serviceAccountAuth = new JWT({
email: creds.client_email,
key: creds.private_key,
scopes: SCOPES,
});
const doc = new GoogleSpreadsheet(googleSheetId, serviceAccountAuth);
I suspect this error is due to the VPN and possibly related to Google's restrictions in China. How can I resolve this issue and successfully authenticate with Google's OAuth2 service while using a VPN in China? Any insights or workaround suggestions would be greatly appreciated. Thank you!
Note: I've tested this code with a friend located in Morocco, and it works fine on their laptop without any issues.