Php Google oauth2服务api密钥无效

Php Google oauth2服务api密钥无效,php,oauth-2.0,Php,Oauth 2.0,我使用github中的Google_Oauth2服务在我的网站上通过Google登录 但是今天我们遇到了回调url地址的问题 标识完成后 在返回地址中,我们遇到以下错误 Message: Error calling GET https://www.googleapis.com/oauth2/v2/userinfo?key=%2A%2A%2A2A%2A: (400) API key not valid. Please pass the valid API key. 我们以前没有做过任何改变 密钥

我使用github中的Google_Oauth2服务在我的网站上通过Google登录 但是今天我们遇到了回调url地址的问题 标识完成后

在返回地址中,我们遇到以下错误

Message: Error calling GET https://www.googleapis.com/oauth2/v2/userinfo?key=%2A%2A%2A2A%2A: (400) API key not valid. Please pass the valid API key.
我们以前没有做过任何改变


密钥和api密钥是正确的

我遇到了这个问题,当我试图通过HTTP获取配置文件信息时,我将
客户端id
作为
密钥URL参数传递https://www.googleapis.com/oauth2/v2/userinfo
请求,但在本月某个时候之后,我收到了“API密钥无效。请传递有效的API密钥。“

旧代码:

$headers = ["Authorization: Bearer " . $tokenResp['access_token']];
$oauthInfo = json_decode(file_get_contents('oauth-credentials.json'), true);
$params = [
  "key" => $oauthInfo['web']['client_id']
];
$userInfo = HTTPGet('https://www.googleapis.com/oauth2/v2/userinfo', $params, $headers);
我去了谷歌控制台,找到了我创建oauth信息的同一个项目,“凭证”(左导航)点击蓝色的“创建凭证”按钮,选择“API密钥”,并使用那里提供的键值作为
https://www.googleapis.com/oauth2/v2/userinfo
解决了我的问题

新代码(刚刚更改了行):

使用我生成的API密钥而不是客户端id

  "key" => "AIz........................JWUM"