我有像头衔这样的问题。我登录oauth2,谷歌返回错误
“无法读取未定义的属性'spreadsheets‘”。我尝试从google页面复制样本,但同样的错误;
function makeApiCall() {
var spreadsheetBody = {
// TODO: Add desired properties to the request body.
};
var request = gapi.client.sheets.spreadsheets.create({}, spreadsheetBody);
request.then(function(response) {
// TODO: Change code below to process the `response` object:
console.log(response.result);
}, function(reason) {
console.error('error: ' + reason.result.error.message);
});
}
function initClient() {
var SCOPE = 'https://www.googleapis.com/auth/spreadsheets';
gapi.client.init({
'apiKey': 'myke',
'clientId': 'myclientID',
'scope': SCOPE,
// 'discoveryDocs': ['https://sheets.googleapis.com/$discovery/rest?version=v4'],
}).then(function() {
gapi.auth2.getAuthInstance().signIn();
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSignInStatus);
updateSignInStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
});
}
function updateSignInStatus(isSignedIn) {
if (isSignedIn) {
makeApiCall();
}
}
gapi.load('client:auth2', initClient);发布于 2020-03-05 12:39:01
这是因为您注释掉了"Discovery Docs“行。GAPI需要知道发现文档,以便加载正确的API端点。
https://stackoverflow.com/questions/53636377
复制相似问题