Google 人 API 返回 'The request is missing a valid API key.'

Google People API Returning 'The request is missing a valid API key.'

我没有对我的 Chrome 扩展中的 Google 表格集成进行任何代码更改(仅在我们公司内部使用)。今天,我收到消息 "The request is missing a valid API key."

的“403”错误

我没有使用 API 密钥并且从来没有使用过 - 只是一个客户端 ID。这多年来一直很棒,直到今天或昨天。

我的范围是https://www.googleapis.com/auth/spreadsheets and https://www.googleapis.com/auth/userinfo.profile

有什么想法吗?这里有什么我不知道的变化吗?我确实看到了这个:https://github.com/zquestz/omniauth-google-oauth2/issues/106 但时间框架与我所看到的不一致。

我遇到了同样的问题,解决方法是手动设置 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});
      });
  });
}