I'm using the Google O Auth 2.0 PHP API Client Library to authorize my app and get access tokens and refresh tokens. I do get access tokens.
The JSON returned has an access_token, token_type, expires, and id_token, I believe, but it doesn't have a refresh_token.
I've tried getting just the refresh_token with the library, but I get NULL.
This is the first authorization because I am using prompt=consent
parameter in my url redirect and am manually disapproving my app in the Google accounts console each time before doing this, still not getting a refresh token.
Here is my code which gets the access token successfully, but no refresh token:
$client = new Google_Client();
$client->setAuthConfig('php/client_secret.json');
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
$client->addScope(array('email', 'profile', 'calendar'));
$token=$client->fetchAccessTokenWithAuthCode(urldecode($authCode));
Here is my code that returns null for the refresh token:
$client = new Google_Client();
$client->setAuthConfig('php/client_secret.json');
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
$client->addScope(array('email', 'profile', 'calendar'));
$client->authenticate(urldecode($authCode));
$token=$client->getRefreshToken();