Как взаимодействовать Google Spreadsheets с ботом Telegram с помощью Node? - PullRequest
0 голосов
/ 30 марта 2020

Я использую служебную учетную запись для управления своей собственной электронной таблицей, я знаю, что мой скрипт работает, потому что я попробовал его напрямую с помощью Node (работает node myScript.js)

Мой сценарий выглядит так:

const { GoogleSpreadsheet } = require('google-spreadsheet');

async function start() {
    const creds = require('./creds-from-google.json');
    const sheetID = 'my spredsheets URL id here';
    const doc = new GoogleSpreadsheet(sheetID);

    await doc.useServiceAccountAuth({
        client_email: creds.client_email,
        private_key: creds.private_key,
    });


    await doc.loadInfo(); // loads document properties and worksheets
    console.log(doc.title);

    const sheet = doc.sheetsByIndex[0];
    console.log(sheet.title);

    const data = {
            'Title': 'my title here',
            'Content': 'my content here'
    };
    return sheet.addRow(data);
}
start();

Но когда я выполняю этот код ботом Telegram, он получает ошибку 401.

Сообщение об ошибке:

Google API error - [401] Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...