I have been searching around and reading the php library to figure out the best way to have permanent authentication after the first initial oAuth request.
The code below seems to work fine, but my question is in regards to
$client->refreshToken($refresh_token);
EDIT: I read some more of the code and this does NOT appear to be the correct way. I tried using my refresh token when calling setAccessToken
, but that didn't work either. Is this documented anywhere?
Is this the correct way to set the refresh token? Will this token expire?
<?php
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
$client_id = 'CLIENT ID';
$client_secret = 'CLIENT SECRET';
$refresh_token = 'REFRESH TOKEN';
$client = new Google_Client();
// Get your credentials from the APIs Console
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri('http://redirecturl.com');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
$client->setAccessType('offline');
$client->refreshToken($refresh_token);
?>