Locations not appearing when using User Credential[ Edited ]
June 2016 - last edited June 2016 by Terry W
Can someone please clarify the use of locations and Google accounts? My company has two Google logins, the 'business' login and the 'developer' login. The project whitelisted for Google My Business API was created through the 'developer' login, but it is the 'business' login which has the top-level Google My Business access (and therefore the locations).
The problem I am having is this:
My project (using C# Client Library) currently creates a credential and service, then gets accounts and locations using the appropriate 'list' commands.
- if I connect with a UserCredential then I get back a 'personal' type account. If I try to get locations for this, none are found.
- but if I connect with a ServiceAccountCredential then I get back a 'business' type account.. and I can then get the locations for this account.
If I try to use OAuth2 playground, it only gives me the personal account and no locations (same as using the UserCredential). This isn't ideal because I wanted to use the Playground to try to solve the other issue I've posted about (error 400 when doing Patch location). - I'd hoped the Playground would give me more detailed info on that error.
So, should the project for GMB have been created against the 'business' account rather than the 'developer' one ? Would this have allowed the locations to come back using the UserCredential / playground?
If it is set up correctly, is there any way of using the 'business' account in the Playground so that I can get the locations to be listed? (Or alternatively, getting the locations to come back using the UserCredential)?
(Edited to add): I've found out that Managers can be added to accounts. Would a solution be to add the 'developer' login as a manager to the business account?
Re: Locations not appearing when using User Credential[ Edited ]
June 2016 - last edited June 2016
Hi @Shark S,
We see that your company has two Google Accounts for Google My Business, one for the business with locations and the other for the developers that your whitelisted project was created under. If you are using a service account for authentication, please note that a one-time user consent is required for a service account to be able to access the Google My Business account and location data on behalf of a particular end user. If the end users later want to revoke the application’s access to their Google My Business account and location data, they can remove the authorized app from the Apps connected to your account page of their accounts.
When you are using OAuth 2.0 Playground to experiment with the Google My Business API, you should be logging in with your business Google Account using the whitelisted project’s credentials from your developers Google Account to obtain an OAuth 2.0 access token for authentication via the API. This user consent process is the same for the authorization of your application during the OAuth 2.0 installed application flow. When this token is provided and you are making API calls, you will be able to view and manage all the existing locations within your business Google Account. You can perform this user consent process with a single set of OAuth 2.0 credentials from the whitelisted project for different Google Accounts individually to access the account and location data in a specific Google Account.
In addition, when using the OAuth 2.0 client ID for authorization, you should store the refresh token for future use and use the access token to access the API. Once the access token expires, the application should use the refresh token to obtain a new one. This way, your application will always be able to request a new access token when necessary. This process requires a user to manually authorize the application only once.
The access to the locations in your business Google Account is determined by whether you are logged in with your business Google Account for user consent during OAuth 2.0 authorization and not which Google Account you created your whitelisted project in. We recommend using business accounts to share access to a large set of locations with a group of people between your business Google Account and developers Google Account. Please check out the the best practices for using Business Accounts with Google My Business locations in the FAQ. The locations that you share in a business account will be available across both your business and developers Google Accounts so that you should be able to access different sets of locations in one Google Account using a single access token via the API.