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

How to get help on how to use My Business API

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

Hi

 

How do we get support in using the My Business API?  The only example I can find does not work and when I've asked here for help there has been complete silence.

 

As far as I can tell we are fully authorised and have a whitelisted project but the error message I am getting is totally unhelpful and there seem to be very little relevant documentation or examples.

 

 

Regards

John

1 Expert replyverified_user

Re: How to get help on how to use My Business API

Google Employee
# 2
Google Employee

Hi @SPAR D,

 

I’ve posted a reply to help you resolve the problem you are having with the Java client library. The full set of URIs used for each supported operation in the API is summarized in the Google My Business API Reference document. You can find Java Code Samples to Work with Account Data, Work with Location Data, Work with Review Data and Manage Real-time Notifications on our Google Developers site.

 

In addition, I suggest you Get Started by following the Make a simple HTTP request step-by-step guide on the Google Developers site to learn how to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.

 

I hope this helps. Thank you for your patience!

 

Thanks,

Terry

How to get help on how to use My Business API

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Terry

 

Thanks for the reply; I've tried using the "Get Started" guide but when I get down Step 7 ("Under Step 1 Select & authorize APIs, paste the scope for the Google My Business API into the field labeled Input your own scopes: https://www.googleapis.com/auth/plus.business.manage") I get thsi error message:

 

   400. That’s an error.

   Error: redirect_uri_mismatch

   That’s all we know.

 

It sounds to me like something is set up wrong in my account or the OAuth token, what do you think?

 

Regards

John

 

Re: How to get help on how to use My Business API

Google Employee
# 4
Google Employee

Hi @SPAR D,

 

You received that error because you didn’t complete the below step 1 & 2 of the Make a simple HTTP request guide and set the redirect URI for OAuth 2.0 Playground:

  1. Go to the Google API Console, open your project, and go to the Credentials section. If you don't have a client ID for web applications, create one now.
  2. Under Client ID for web application, click Edit settings and add https://developers.google.com/oauthplayground as a valid redirect URI.

 

I suggest you read through the Basic steps of OAuth 2.0 authentication and authorization.

 

Thanks,

Terry

How to get help on how to use My Business API

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi Terry

 

OK, I can see now that the error I made was in reusing the existing OAuth token, I've created a new one now (the type I had previously configured was the wrong type) and instead of getting the meaningless error message "That's an error" I can now "Accept" and get back to the playground.  

 

So onto the next step - I have used "Step 3 Configure request to API" as instructed by Step 10 of the guide (the guide refers to Step 2, but Step 2 is "Exchange Authorisation code for tokens" but the playground responds:

 

GET /v3/accounts HTTP/1.1
Host: mybusiness.googleapis.com
Content-length: 0
Authorization: Bearer 
 
HTTP/1.1 401 Unauthorized
Content-length: 136
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Cache-control: private
Date: Thu, 13 Oct 2016 19:49:09 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
Content-type: application/json; charset=UTF-8
Www-authenticate: Bearer realm="https://accounts.google.com/", error="invalid_token"
{
 
"error": {
   
"status": "UNAUTHENTICATED",
   
"message": "Request had invalid authentication credentials.",
   
"code": 401
 
}
}

 

WTF?  Well, there's more text in that response but semantically it doesn't seem more helpful than "That's an error".

 

Is "Step 2 Exchange Authorisation code for tokens" supposed to be missed out?  Thanks for the the basic steps of OAuth but AFAICT that's just an overview on how OAuth works under the hood, whereas I'm trying to follow your step by step guide to using your playground here (and actually, what I'm *really* trying to do is use the client APIs that are a layer above the playground anyway!)

 

Does this mean that perhaps the reason the client API is not working is because Im using the wrong type of OAuth client ID?  What *should* it be to connect from a Java application, "Other" or "Web application"?

 

Regards

John

 

Re: How to get help on how to use My Business API

[ Edited ]
Google Employee
# 6
Google Employee

Hi @SPAR D,

 

You are most likely missing the following steps in the Make a simple HTTP request guide:

  1. Under Step 1 Select & authorize APIs, paste the scope for the Google My Business API into the field labeled Input your own scopes: https://www.googleapis.com/auth/plus.business.manage
  2. Click Authorize APIs.
  3. Click Accept when prompted.

 

If your OAuth flow is set to Server-side, you can check the “Auto-refresh the token before it expires.” checkbox under Step 2 Exchange authorization code for tokens to automatically refresh the access token when it expires, or press the “Refresh the access token” button to manually refresh the access token; If your OAuth flow is set to Client-side, and it’s shown that “The access token has expired.” under Step 1's result Access token retrieved, you should repeat step 8. Click Authorize APIs. to authorize and retrieve the access token again.

 

For using the OAuth 2.0 Playground, you should create an OAuth 2.0 client ID for a Web application by selecting "Web application" as the application type.

 

For using my code snippet for an Installed application, you can create an OAuth 2.0 client ID for either a Web application by selecting "Web application" as the application type and set a redirect URI to something like http://localhost/Callback, or an Installed application by selecting "Other" as the application type.

 

It’s very important for you to understand what’s going on under the hood during OAuth 2.0 Authorization and the RESTful APIs basics. Otherwise, you wouldn’t be able to understand the code snippets I provided and all the Java Code Samples we provide on the Google Developers site. The OAuth 2.0 Playground is good place for your to experiment with the OAuth 2.0 protocol and learn REST in the Google My Business API by making various types of requests before you start implementing your application.

 

Thanks,

Terry

How to get help on how to use My Business API

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi Terry

 

Thanks for persisting with this, but I didn't miss that step out.  I've just done it again to be sure and it still gives the same error.

 

However, I also used a browser I've never used to connect to the playground before (Firefox) and this time, Step 2 in the playground is "Configure request to API" (not Step 3) and the test works.

 

I've tried it again with Safari but hit the same problem as before; it seems that something didn't work right and this caused Step 2 to become "Exchange authorization code for tokens", whereas on Firefox I get "Step 1's result Access token retrieved" and then the "Step 2 Configure request to API" as expected by the instructions.

 

Here's a picture of what happens in Safari: http://2.1m.yt/gvUEpmb.png - note that although the response is a 302, I was presented with the page that asked me to accept the API access and I clicked "Allow".

 

Regards

John

 

 

Re: How to get help on how to use My Business API

[ Edited ]
Google Employee
# 8
Google Employee

Hi @SPAR D,

 

According to the Make a simple HTTP request guide, you are supposed to:

  1. Click the gear icon to open the configuration options and make the following changes:
    1. Set OAuth flow to Client-side.
    2. Check Use your own OAuth credentials.
    3. Paste in your OAuth client ID.

 

Apparently, you have set the OAuth flow to Server-side according to your screenshot. You can either set OAuth flow to Client-side and repeat all required steps, or press on the “Exchange authorization code for tokens” blue button as shown in your screenshot to retrieve the access token. If your OAuth flow is set to Server-side, you can check the “Auto-refresh the token before it expires.” checkbox under Step 2 Exchange authorization code for tokens to automatically refresh the access token when it expires, or press the “Refresh the access token” button to manually refresh the access token; If your OAuth flow is set to Client-side, and it’s shown that “The access token has expired.” under Step 1's result Access token retrieved, you should repeat step 8. Click Authorize APIs. to authorize and retrieve the access token again.

 

In addition, please make sure that you provide the valid OAuth Client ID if your OAuth flow is set to Client-side. If your OAuth flow is set to Server-side, you should provide both the valid OAuth Client ID and the valid OAuth Client secret.

 

Thanks,

Terry