googleapis / google-api-nodejs-client

Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
https://googleapis.dev/nodejs/googleapis/latest/
Apache License 2.0
11.27k stars 1.91k forks source link

Unable to fetch My Business Reviews from a location. #3513

Open ktist opened 3 days ago

ktist commented 3 days ago

Since the mybusiness.googleapis.com/v4 API is not managed (according to my knowledge and research at least) by the google-api-nodejs-client, and having the need to work with review data on my application both to fetch all locations' reviews and reply to some of them, I have resorted to manually invoke the the client.request({url}) to perform this request.

To my understanding as of today, all of the mybusiness.googleapis.com/v4 API is being deprecated, expect some features like review handling as per Google's documentation (Review handling , accounts.locations.reviews.list ) hence the reason why methods for calls to mybusiness.googleapis.com/v4 API is not present on your library.

The client.request({url}) works as intended for every other API URLs I need, so I can assume nothing is wrong with my codebase, although here is a brief example of the implementation:

  const client = new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
  client.setCredentials(tokens);
  const url = `https://mybusiness.googleapis.com/v4/accounts/-/locations/${loccationID}/reviews`;
  client
    .request({ url })
    .then((data) => {
      console.log(data);
    })
    .catch((err) => {
      console.log(err);
    });

No matter any different methods I have tried (even on google's oAuth playground), I am getting this error:

Sending a request to `https://mybusiness.googleapis.com/v4/accounts/accID/locations/locID/reviews`; returns the following message: 'Google My Business API has not been used in project "projectNumber" before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project="projectNumber" then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.'

When I access the above URL I am getting a 404 error (as you will too if you check that by changing projectNumber to your project number) indicating that this API cannot really be enabled. When I search specifically for the mybusinessapi, I can only find the 8 other APIs (like mybusinessnotifications etc) that, for troubleshooting purposes, have all been enabled.

I am missing a feature of the google-api-nodejs-client, or am I not reading the documentations (Review handling , accounts.locations.reviews.list ) correctly?