Created
June 16, 2024 14:29
-
-
Save PaulieScanlon/6cef226dc0b81f40e3290252b02e4fe5 to your computer and use it in GitHub Desktop.
Google Sheet service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./services/google-spreadsheet.ts | |
import { GoogleSpreadsheet } from 'google-spreadsheet'; | |
import { JWT } from 'google-auth-library'; | |
const serviceAccountAuth = new JWT({ | |
email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL, | |
key: process.env.GOOGLE_PRIVATE_KEY.split(String.raw`\n`).join('\n'), | |
scopes: ['https://www.googleapis.com/auth/spreadsheets'], | |
}); | |
export const doc = new GoogleSpreadsheet(process.env.GOOGLE_SHEET_ID, serviceAccountAuth); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment