消息:{“错误”:{“代码”:401,“消息”:“请求的身份验证凭据无效

时间:2021-07-30 12:03:36

标签: php

我的代码

$client = new Google_Client();
$client->setApplicationName('democommerce');
$client->setClientId($cid);
$client->setClientSecret($secret);
$client->setRedirectUri('https://merchant.intelicle-web.co.uk');
$client->setScopes('https://www.googleapis.com/auth/content');

if (isset($_SESSION['oauth_access_token'])) {
  $client->setAccessToken($_SESSION['oauth_access_token']);
} elseif (isset($_GET['code'])) {
  $token = $client->authenticate($_GET['code']);
  $_SESSION['oauth_access_token'] = $token;
} else {
  header('Location: ' . $client->createAuthUrl());
  exit;
}

它抛出错误不知道发生了什么问题

<块引用>

Message: { "error": { "code": 401, "message": "请求的身份验证凭据无效。需要 OAuth 2 访问令牌、登录 cookie 或其他有效的身份验证凭据。请参阅 https://developers.google.com/identity/sign-in/web/devconsole-project.","错误”:[ {“消息”:“无效凭据”,“域”:“全局”,“原因”:“authError”,“位置”:“授权”,“位置类型”:“标题”}],“状态": "未认证" } }

0 个答案:

没有答案