title: Google Client: Refreshing RefreshToken gives "invalid_grant" error
body: <p>currently I have a problem with some accessTokens. I am using YouTube Data API and YouTube Analytics API to get some data from YouTube Channels.</p>
  
  <p>For authentication I set the "state" to "offline" and "approvalPrompt" to force. So I get a refresh Token with the authentication. To refresh an access Token with refresh Token, I use the following code:</p>
  
  <pre><code>$client-&gt;setAccessToken("ACCESSTOKEN");
  
  if( $client-&gt;isAccessTokenExpired() ) {
    $client-&gt;refreshToken($refresh_token);
  }
  </code></pre>
  
  <p>After that, I do some request to Google API. But when I execute a request, Google returns the following error:    </p>
  
  <blockquote>
    <p>exception 'Google_Auth_Exception' with message 'Error refreshing the
    OAuth2 token, message: '{   "error" : "invalid_grant" }'' in
    /var/www/vhosts/xxx.com/httpdocs/app/library/google-api-php/src/Google/Auth/OAuth2.php:345
    Stack trace:
    0 /var/www/vhosts/xxx.com/httpdocs/app/library/google-api-php/src/Google/Auth/OAuth2.php(269):
    Google_Auth_OAuth2->refreshTokenRequest(Array)
    1 /var/www/vhosts/xxx.com/httpdocs/app/library/google-api-php/src/Google/Auth/OAuth2.php(243):
    Google_Auth_OAuth2->refreshToken('1/oiq78SCfplnl-...')
    2 /var/www/vhosts/xxx.com/httpdocs/app/library/google-api-php/src/Google/Service/Resource.php(171):
    Google_Auth_OAuth2->sign(Object(Google_Http_Request))
    3 /var/www/vhosts/xxx.com/httpdocs/app/library/google-api-php/src/Google/Service/YouTube.php(1694):
    Google_Service_Resource->call('list', Array, 'Google_Service_...')
    4 /var/www/vhosts/xxx.com/httpdocs/app/tasks/CronjobTask.php(51): Google_Service_YouTube_Channels_Resource->listChannels('snippet,brandin...', Array)</p>
  </blockquote>
  
  <p>Does anybody know, what the problem is? I also updated the server time, because I read that Google could have a problem with it. But this doesn't fix the problem.</p>
  
  <p>Hint: This only happens to some accessTokens. I have several access Tokens where this code works fine. Yet there are other access Token where this code doesn't work, an I get the error above. <strong>Could it be that the person revoked access for my app? Could this be a reason for this error message?</strong></p>