OAuth 2.0刷新令牌不可用


OAuth 2.0 refresh token is not available?

我有一个基于web的应用程序,它使用Google OAuth2.0作为登录框架。它以前工作得很好,直到昨天。访问令牌过期后,应用程序无法获取刷新令牌。

如何删除以下错误?

**PHP Fatal error**: Uncaught exception 'Google_AuthException' with message 'The OAuth 2.0 access token has expired, and a refresh token is not available.

以下是我的代码:

if (isset($_GET['code'])) {
  $client->authenticate($_GET['code']);
  $_SESSION['access_token'] = $client->getAccessToken();
  header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}

if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
  $client->setAccessToken($_SESSION['access_token']);
}

OAuth2访问令牌可能会过期,您必须使用"刷新令牌"来刷新它——它总是与访问令牌一起使用。