invalid_grant:代码已被兑换为Google Oauth

I am trying to authorize my application to read the google drive of users, but keep running into the above problem. Here is my code:

session_start();

$client = new Google_Client();
$client->setClientId(CLIENT);
$client->setClientSecret(SECRET);
$client->setRedirectUri(REDIRECT);
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);

if (! isset($_GET['code'])) {
  $auth_url = $client->createAuthUrl();
  header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
  $client->authenticate($_GET['code']);
  $_SESSION['access_token'] = $client->getAccessToken();
  //$redirect_uri = 'http://'.$_SERVER['HTTP_HOST'];
  //header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}

I understand that my application has already received a token, and it was already redeemed. My question is how can I access the refresh token, and feed that to the application instead? I have also read that clearToken(context, token), does the trick, but I do not know where to implement that in my code and with what context parameter.

"received a token, and it was already redeemed" Do you mean Access Code?

Assuming you requested offline access, then redeeming the Access Code will return a Refresh Token, which you should store securely for when you need it.

If you forgot to store the Refresh Token, then you'll need to revoke access and start again.