I want to access the locations associated with my account and their reviews, for that I am using the google my business API and I have access to it (it does work on oAuthplayground).
Now I want to access the google my business api without logging into my account, for that I am trying to make it work with the service account. But no luck so far, please advice how to proceed with this. I have enabled the G suite in the service account and I have also tried to give access to the service account email (ID) for the my business manage but it stays in Invited state, as there is no way to actually accept the invite.
When I try to send request using my account as subject.
$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/plus.business.manage');
$client->setAuthConfig(dirname(__FILE__) . '/Xyz Review API-service account.json');
$client->setSubject('xyz*****abc@gmail.com');
$business_service_class = new Google_Service_Mybusiness($client);
$result_accounts = $business_service_class->accounts->listAccounts();
echo json_encode($result_accounts);
exit;
Response: {"nextPageToken":null}
If I use the google service account ID as email id in subject then I get following response.
$client->setSubject('xyz-review-service@xyz-review-api.iam.gserviceaccount.com');
Response: Error 500 { "error": "unauthorized_client", "error_description": "Unauthorized client or scope in request." }
If I am doing this completely wrong then please do advice how to proceed with this. Thank you.