We are trying to build a service to export google drive files for in our gsuite domain.
We're working with the https://github.com/google/google-api-php-client
We made a service user, downloaded and saved the user credentials and granted domain-wide-access to the service user.
With the simplest example like below (like in every doc, i found):
putenv('GOOGLE_APPLICATION_CREDENTIALS='/service-account-credentials.json');
$client = new \Google_Client();
$client->setAuthConfig('service-account-credentials.json');
$client->setScopes('https://www.googleapis.com/auth/drive.file');
$client->useApplicationDefaultCredentials();
$client->setSubject('admin@mydomain.com');
$service = new \Google_Service_Drive($client);
$service->files->listFiles();
as soon as we include the line $client->setSubject('admin@mydomain.com');
it's dropping the following error:
{
"error": "unauthorized_client",
"error_description": "Client is unauthorized to retrieve access tokens using this method."
}
has anyone an idea, or can share a code sample for this problem. It's a real blocker for us and for now I don't have any idea why this error appears