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

Get all store details using GMB

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

Hi,

 

I am trying to develop a cron job to fetch all the store details for a client from GMB account, hence I will not be able to whitelist a domain.

I followed all the steps given in https://developers.google.com/my-business/content/get-started#make_a_simple_http_request but when

I try to authorizing API in OAuth 2.0 playground using "https://www.googleapis.com/auth/plus.business.manage" it takes me to a 404 page. Please advise if I am doing something wrong.

 

Please if you can provide me a link to download all the store details in JSON format that would be great.

Any help is highly appreciated.

 

Regards

Pushkar

1 Expert replyverified_user

Get all store details using GMB

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Update: Now I am able to get a response from OAuth 2.0 playground. But, the irony is I don't understand the use of it!

 

My query is pretty simple, I have all the required credentials but I need a proper way to fetch all the store details from Google My Business.

Could someone please explain or share a detailed note on same.

Re: Get all store details using GMB

Google Employee
# 3
Google Employee

Hi @Pushkar M,

 

The 404 Method not found error typically happens when you are using a different Project ID from the one we whitelisted for your company to access the Google My Business API. Please make sure you use the whitelisted project id while using the Google My Business API.

 

You can get the list of locations for the specified account in JSON format by sending a GET http request using the Google My Business API in the OAuth 2.0 Playground. We suggest you checkout this thread on how to lists the locations using the Google My Business API.

 

Thanks,

The Google My Business API team

Get all store details using GMB

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi @Shalini S,

Thanks for the reply.

Using OAuth 2.0 Playground I am able to fetch all the location records.
But, please note that we are trying to build a windows service hence we will not be able to whitelist any URI on console dashboard.

Could you please provide us a sample code wherein we could simply write and read the authentication token on a local response file and further use this token to call functions in GMB service without whitelisting any URI.

We have taken reference from one of our previous projects where we used DFAService but the same code is failing for GMB service.

Please see our code snipit below to create Auth token but are failing to do so:

// Credential for accessing Google APIs
UserCredential Credential;
IEnumerable<string> scopes = new[] { "https://www.googleapis.com/auth/plus.business.manage" };
// Use the local client_secrets.json file
using (var stream = new System.IO.FileStream("c:/Tokens/Google/APIGMB/client_secret.json", System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
// Fetch credential
Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, scopes,
"pushkarMishra@gmail.com", CancellationToken.None, new FileDataStore("c:/Tokens/Google/APIGMB/doubleclick.auth.store", true));
}

Evertime Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync gets executed it throws an error "http://localhost:27962/authorize/, does not match the ones authorized for the OAuth client."

 

Regards,
Pushkar Mishra

Re: Get all store details using GMB

Google Employee
# 5
Google Employee

Hi @Pushkar M,

 

There’s a guide on our API documentation website for setting up the Java Client LibraryWhen you have an OAuth 2.0 client ID for authentication and authorization, you should use the OAuth 2.0 installed application flow and persist the refresh token. 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 during the OAuth 2.0 installed applications flow only once.

 

If you use the access_type=offline parameter during the authorization code flow, you can retain a long-lived refresh token, which is typically received along with the access token.

 

You can use the following code snippet for persisting the refresh token with the Java Client Library:

// set up authorization code flow
  GoogleAuthorizationCodeFlow flow =
      new GoogleAuthorizationCodeFlow.Builder(
              httpTransport,
              JSON_FACTORY,
              clientSecrets,
              Collections.singleton("https://www.googleapis.com/auth/plus.business.manage"))
          .setDataStoreFactory(dataStoreFactory)
          .setAccessType("offline")
          .setApprovalPrompt("force")
          .build();
  // authorize
  return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

 

I hope this helps get you started.

 

Thanks,

The Google My Business API team

Get all store details using GMB

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi @Shalini S,

 

I believe we are going round n round on the same issues.

 

I am working on a C# project where I need to incorporate Google my business to import all the store locations.

Please note that this is not a web application hence giving inputs is not an option.

I have completed all the steps to fetch store locations and I am able to do it on OAuth playground. 

 

I NEED A GOOGLE MY BUSINESS RUNNING SAMPLE, PLEASE DO NOT PROVIDE URLs FOR ANY OTHER API SAMPLES.

As SCOPE IS NOT AVAILABLE FOR GMB according to https://developers.google.com/identity/protocols/googlescopes

 

PLEASE HELP ME GET THIS ISSUE RESOLVED ASAP.

 

Regards

Pushkar

Get all store details using GMB

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi @Shalini S,

 

Sorry for an anxious reply but I seriously need help on the above queries.

Could you please help me with the same.

 

Regards

Pushkar

Get all store details using GMB

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

Hi @Shalini S,

 

 

Still awaiting a reply.

 

Regards

Pushkar