Google表格浏览器API权限

时间:2018-09-11 00:38:41

标签: javascript google-sheets-api

我目前正在编写一个程序,该程序使用Google表格浏览器API从Google Spreadsheet读取和写入数据。

程序成功读取电子表格并将数据上传到表中。 (因为这样做有效,所以我不会导入代码以节省空间。)

但是,在尝试将数据写入电子表格时,出现错误:

"error": {↵ "code": 403,↵ "message": "The caller does not have permission"

我使用相同的initClient()和其他函数通过添加写数据函数来授权API:

范围:

var SCOPES = "https://www.googleapis.com/auth/drive.file";

功能:

function write_sheets() {
        var values = [
            [
                // Cell values ...
            ],
            // Additional rows ...
        ];
        var body = {
            values: values
        };
        gapi.client.sheets.spreadsheets.values.append({
            spreadsheetId: "Same ID as Read",
            range: "A2:G2",
            valueInputOption: "RAW",
            resource: body
        }).then((response) => {
            var result = response.result;
            console.log(`${result.updates.updatedCells} cells appended.`)
        });
    }

我正在使用的google帐户对电子表格具有编辑权限。授予文件的帐户所有权不会更改该错误。

0 个答案:

没有答案
相关问题