Using Service Account to access GMB info

Viewed 291

I am trying to create a program which will retrieve info form GMB automatically (no front end, the app will run automatically everyday.) The problem I face is that the service account ( example: company-2@company-locator-158221.iam.gserviceaccount.com ) is not retrieving any data. For example, with the code:

putenv('GOOGLE_APPLICATION_CREDENTIALS=company-locator-6f6a81a3384285.json');
$user   = "company-2@company-locator-158221.iam.gserviceaccount.com";
$client->setSubject($user);

The result is a json with NULL information inside the arrays returned.

If I use the code:

putenv('GOOGLE_APPLICATION_CREDENTIALS=company-locator-6f6a81a8sd4285.json');
$user   = "digitalcompany@mycompany.com";
$client->setSubject($user);

The result is the error "Client is unauthorized to retrieve access tokens using this method." which is expected because digitalcompany@mycompany.com is the bussiness account which I use to log unto MyBussines, not a service account.

So basically: -How can I make the service account company-2@company-locator-158221.iam.gserviceaccount.com to be able to "see" all the info on the digitalcompany@mycompany.com GMB account (all the API configuration, credentials, etc are on the digitalcompany@mycompany.com account ) ? Or -Is there a way to make the service account impersonate the bussines account, so it can "see" the GMB information?

Thank you!

0 Answers
Related