asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
544 stars 152 forks source link

Access token is invalid #172

Open tomasHegi opened 7 years ago

tomasHegi commented 7 years ago

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.

kavishdahekar commented 7 years ago

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);