Google Spreadsheets API NodeJS

时间:2018-11-05 21:37:51

标签: javascript node.js google-api

嘿,我在理解Google文档中的示例时遇到了问题 https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get?apix_params=%7B%22spreadsheetId%22%3A%221jK2H5goZL8lLBzJNqxycw66BXk-i35S4OK6USqwglj8%22%2C%22includeGridData%22%3Atrue%7D

function authorize(callback) {
// TODO: Change placeholder below to generate authentication 
 credentials. See
// https://developers.google.com/sheets/quickstart/nodejs#step_3_set_up_the_sample
// Authorize using one of the following scopes:
//   'https://www.googleapis.com/auth/drive'
//   'https://www.googleapis.com/auth/drive.file'
//   'https://www.googleapis.com/auth/drive.readonly'
//   'https://www.googleapis.com/auth/spreadsheets'
//   'https://www.googleapis.com/auth/spreadsheets.readonly'
 var authClient = null;

if (authClient == null) {
console.log('authentication failed');
return;
}
callback(authClient);
}

那么,首先,我如何生成身份验证?我尝试从此站点创建新文件:

https://developers.google.com/sheets/quickstart/nodejs#step_3_set_up_the_sample并运行它,我想它起作用了,因为它给了我一个名字和专业的列表。所以我不确定该怎么做。

另外,我声明了变量authClient并将其设置为null,因此当然会出现身份验证失败错误,但是我在'https://www.googleapis.com/auth/spreadsheets'上进行了更改(我做对了吗?) 它给了我一个错误:

Error: API key not valid. Please pass a valid API key.

0 个答案:

没有答案