I am successfully using the Google PHP API with an service account to manipulate Google CloudDNS records like this:
$permisson = 'https://www.googleapis.com/auth/ndev.clouddns.readwrite';
$client = new Google_Client();
$client->setApplicationName("foo");
$credentials = new Google_Auth_AssertionCredentials(
$googleApiServiceAccount,
array($permission),
file_get_contents($googleApiKeyFile)
);
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($credentials);
}
$accessToken = $client->getAccessToken();
[..]
Is it possible to use a similar scheme for Google Apps Spreadsheets access? What to use as $permission and what kind of API do i have to enable in the Google Developer Console?
Please note: I am fully aware of the fact that it is easy to access the API via oAuth2 - i am looking for a way to access it via a service account.