php-google-spreadsheet-client icon indicating copy to clipboard operation
php-google-spreadsheet-client copied to clipboard

Access token is invalid

Open tomasHegi opened this issue 8 years ago • 1 comments

Hi, when trying to connet to spreadsheet and retrieve spreadsheets I am getting following error: access token is invalid.

$client = $this->getClient(); $token = $client->getAccessToken(); $serviceRequest = new DefaultServiceRequest($token['access_token']); ServiceRequestFactory::setInstance($serviceRequest);

I don't think, that access token is invalid cause I could connect via Google_Service_Sheets.

Thanks in advance.

tomasHegi avatar Mar 22 '17 18:03 tomasHegi

Facing the same issue. While generating the access token, I tried all the three options below :

1. $client->addScope(Google_Service_Drive::DRIVE);
2. $client->addScope("https://www.googleapis.com/auth/spreadsheets");
3. $client->addScope("https://spreadsheets.google.com/feeds");

But still getting the "Access token is invalid" error.

Complete code snippet below:

$google_api_credentials = 'creds.json';
$client = new Google_Client();
$client->setAuthConfig($this->google_api_credentials);
$client->addScope("https://www.googleapis.com/auth/spreadsheets");
$redirect_uri = site_url('gsheet/handleAuthRedirect');
$client->setRedirectUri($redirect_uri);

kavishdahekar avatar Mar 27 '17 17:03 kavishdahekar