My goal is to make a simple request on Google Fusion Tablesbehalf of my users of web applications. To do this, I created a service account in the Google console. Here is the code:
$client = new \Google_Client();
$serviceAccountName = 'XXXXX.apps.googleusercontent.com';
$scopes= array(
'https://www.googleapis.com/auth/fusiontables',
'https://www.googleapis.com/auth/fusiontables.readonly',
);
$privateKey=file_get_contents('/path/to/privatekey.p12');
$privateKeyPassword='notasecret';
$credential = new \Google_Auth_AssertionCredentials($serviceAccountName,
$scopes, $privateKey, $privateKeyPassword);
$client->setAssertionCredentials($credential);
$service = new \Google_Service_Fusiontables($client);
$sql = 'select name from XXXXXXXX';
$result = $service->query->sql($sql);
After running this code, I got this error:
Error refreshing the OAuth2 token, message: '{
"error" : "invalid_grant"
}'
I googled that for many days, and most of the answers talk about updating the token. I made this update, but still the same mistakes!
Any idea to solve this problem? Thanks
source
share