I want to access the locations associated with my account and their reviews, for this I use the google API for my business and I have access to it (it works on oAuthplayground).
Now I want to access the google my business api without logging in to my account, because I'm trying to get it to work with the service account. But so far no luck, please advice on how to do this. I included the G-package in the service account, and I also tried to provide access to the email (ID) of the service account to manage my business, but it remains in the Invited state, since there is no way to accept the invitation.
When I try to send a request using my account as a 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;
Answer: {"NextPageToken": null}
If I use the google account id as the email id in the subject, I get the following response.
$client->setSubject(' xyz-review-service@xyz-review-api.iam.gserviceaccount.com ');
Answer: Error 500 {"error": "unauthorized_client", "error_description": "Unauthorized client or scope in the request." }
If I do this completely wrong, please advise how to do it. Thanks.
php google-api google-api-php-client google-my-business-api
Hmmm
source share