私は長い時間のためにそれを使用するためにトークンを取り消したい、私のコードは、スタンダールのリダイレクトで始まる - >入手トークンの流れ:右ここ取り消しトークンのOAuth 2のGoogle API
$code = (array_key_exists('code', $_GET) ? $_GET['code'] : '');
$access_token = json_decode(DB::getToken(), true);
$guzzleClient = new \GuzzleHttp\Client(array('curl' => array(CURLOPT_SSL_VERIFYPEER => false,),));
$this->client = new Google_Client();
$this->client->setHttpClient($guzzleClient);
$this->client->setAuthConfig('client_secret.json');
$this->client->addScope("https://www.googleapis.com/auth/calendar");
$this->client->setAccessType('offline');
$this->client->setApprovalPrompt('force');
$this->client->setAccessToken($access_token);
if(!$code && !$access_token) {
$auth_url = $this->client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
}
if($code && !$access_token) {
$this->client->fetchAccessTokenWithAuthCode($code);
$access_token = $this->client->getAccessToken();
DB::saveToken($access_token);
}
アクセストークンの有効期限が切れている場合、私は場合は、チェックはい私は、トークン取り消しと問題なく、それを使用し続けることを期待:
if($this->client->isAccessTokenExpired()) {
$revoked = $this->client->revokeToken($access_token);
if($revoked) {
$access_token = $this->client->getAccessToken();
}
}
けれども問題が発生すると、エラーが私はToken expired or revoked
エラーメッセージが表示されます。
私はここで間違っていますか?
トークンを無効にした後、再び有効になることを期待しています。
あなたは私の一日を保存しました。ありがとうございました – Jonuux