我没有对我的Chrome扩展中的Google Sheets集成做任何代码更改(仅在我们公司内部使用)。今天,我收到一个'403‘错误,消息是“该请求缺少一个有效的API密钥”。
我没有使用API密钥,也从未使用过--只有一个客户端ID。这几年来一直很棒,直到今天或昨天。
我的作用域是https://www.googleapis.com/auth/spreadsheets和https://www.googleapis.com/auth/userinfo.profile。
有什么想法吗?是不是有什么我没注意到的变化?我确实看到了这个:https://github.com/zquestz/omniauth-google-oauth2/issues/106,但时间框架与我所看到的并不一致。
发布于 2018-01-30 08:35:17
我遇到了同样的问题,修复方法是手动设置OAuth2标记:
gapi.auth.setToken({access_token: oauthToken});对于上下文,下面是我的background.js中的身份验证和初始化流程:
var oauthToken;
chrome.identity.getAuthToken(
{
'interactive': true,
'scopes': <scopes>,
},
function(token) {
oauthToken = token;
// load Google client APIs
window.gapi_onload = authGapi;
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if ((request.readyState !== 4) || (request.status !== 200)) {
return;
}
eval(request.responseText);
};
request.open('GET', 'https://apis.google.com/js/client.js');
request.send();
}
);
var authGapi = function() {
gapi.auth.authorize({
immediate: true,
client_id: <clientId>,
scope: <scopes>,
},
function(response) {
gapi.client.init({
discoveryDocs: [
'https://sheets.googleapis.com/$discovery/rest?version=v4',
]
}).then(function() {
gapi.auth.setToken({access_token: oauthToken});
});
});
}https://stackoverflow.com/questions/48449911
复制相似问题