Search code examples
google-my-business-api

Get list of accounts via Google Business API


Ultimately, I am trying to get all reviews for a business location.

I have gone through the basic setup guide here https://developers.google.com/my-business/content/basic-setup

I have access to the project in Google Cloud Platform and am a manager in Google My Business.

To test things, I am using the OAuth 2.0 Playground. I tried calling https://mybusinessaccountmanagement.googleapis.com/v1/accounts but it just returns details of my own account:

{
  "accounts": [
    {
      "vettedState": "NOT_VETTED", 
      "type": "PERSONAL", 
      "name": "accounts/1234567890", 
      "verificationState": "UNVERIFIED", 
      "accountName": "account name"
    }
  ]
}

I was expecting to see details of the business account?

I tried calling https://mybusiness.googleapis.com/v4/accounts/1234567890/locations/qwertyuiop/reviews but get this:

{
  "error": {
    "status": "NOT_FOUND", 
    "message": "Requested entity was not found.", 
    "code": 404
  }
}

This feels like a permissions problem but I cannot find any information about the requirements or any helpful information at all!

Can anyone help?


Solution

  • The Bearer authorization token needs to generated using the Google account that actually has access to the locations. You seem to be using your personal Google account. Please take a look at the basic setup guide from the documentation on making a simple HTTP request:

    Steps 1-6 are about your application and the general access to the GBP APIs.

    Step 7-8 are about using the Google account that actually has access to the location data. So here, you need to use the business's Google account that has location ownership.