My Business
1.6K members online now
1.6K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

API is not returning accounts and neither locations

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 
I can already connect to My business API:
 
After request accounts with: https://mybusiness.googleapis.com/v3/accounts
 
I got this response:
 
  "accounts": [
    {
      "name": "accounts/107510535593044096331",
      "type": "PERSONAL",
      "state": {
        "status": "UNVERIFIED"
      }
    }
  ]
 
 
And I got an empty strubg: "{}"
 
But in my google my business acount there are 3 company accounts all with locations.
 
 How Can I edit this accounts using the API ?
 
I attached a screenshot with this accounts.
 
image.png
1 Expert replyverified_user

Re: API is not returning accounts and neither locations

Google Employee
# 2
Google Employee

Hi @Marc M,

 

If you are building a service account application, please check out this Accepted Solution to set up your service account application for different Google Accounts. Please make sure that you request user consent and specify the user to impersonate for the Google Account to access its Google My Business data.

 

For sharing access to a large set of locations with a group of people, please also check out the best practices for using Business Accounts with Google My Business locations in the FAQ.

 

Thanks,

The Google My Business API team

API is not returning accounts and neither locations

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

hi @Shalini S,

 

I need to use the API from server side using a Cron Job, so I can not autenthicate usinng oauth2 with user consent.

 

So I'm connecting to API using a service account key, I created a new location using the API and the response is ok (200), but now when I access in My business Web Panel I can't see this new location created.

 

Where is the problem?

 

Thanks

 

Marc

Re: API is not returning accounts and neither locations

[ Edited ]
Google Employee
# 4
Google Employee

Hi @Marc M,

 

Since you are building a service account application, you still have to request user consent involving human interaction for each Google Account that you need to access the Google My Business data from and manually authorize your app during OAuth 2.0 flow at least once prior to authenticating with the public/private key pair. You can request user consent using OAuth 2.0 installed applications flow, OAuth 2.0 web server applications flow or via OAuth 2.0 Playground. However, you don’t have to save your retrieved refresh tokens for a service account application. Instead, you specify the user to impersonate by specifying the email address of the user account for access to their Google My Business data when you prepare to make authorized API calls. This is because a service account is an account that belongs to your application instead of an individual end user with a Google Account. Please check out this Accepted Solution for requesting user consent for a service account application.

 

As you mentioned you are unable to see location in Google My Business UI, the reason is a service account's generated email address is not equivalent to a Google Account’s email address. You can't sign in with your service account's email address to access the Google My Business UI. Therefore, the locations you created in your service account are not accessible via the UI and can’t be verified.

 

I don’t know your programming language preference, but for your reference, this is the Accepted Solution for using a service account with the Google API Client Library for PHP.

 

Thanks,

Shalini