🔒️ fixing issue with service accout key in secrets

This commit is contained in:
ChatonDeAru 2024-04-05 20:19:11 +02:00
parent 21fef73d08
commit 35c3f8e4f8
No known key found for this signature in database
GPG Key ID: 3CADF765A409F755

View File

@ -355,11 +355,12 @@ export class Sheet<
return tryNTimes( return tryNTimes(
async () => { async () => {
if (hasGSheetsAccess()) { if (hasGSheetsAccess()) {
const key = process.env.GCP_SERVICE_ACCOUNT_PRIVATE_KEY || ""
// Authentication // Authentication
const doc = new GoogleSpreadsheet(process.env.GSHEET_ID) const doc = new GoogleSpreadsheet(process.env.GSHEET_ID)
await doc.useServiceAccountAuth({ await doc.useServiceAccountAuth({
client_email: process.env.GCP_SERVICE_ACCOUNT_CLIENT_EMAIL || "", client_email: process.env.GCP_SERVICE_ACCOUNT_CLIENT_EMAIL || "",
private_key: process.env.GCP_SERVICE_ACCOUNT_PRIVATE_KEY || "", private_key: key.replace(/\\n/g, "\n"),
}) })
await doc.loadInfo() await doc.loadInfo()
return doc.sheetsByTitle[this.sheetName] return doc.sheetsByTitle[this.sheetName]