google business place api

43 views Asked by At

We possess a Google Business account for adding locations, and we aim to retrieve all locations using a Node.js application. We've established a project and obtained a service account JSON. Currently, we are attempting to extract location information through Node.js code, but we are encountering difficulties in retrieving all the account details associated with the owner's email.

We possess a Google Business account for adding locations, and we aim to retrieve all locations using a Node.js application. We've established a project and obtained a service account JSON. Currently, we are attempting to extract location information through Node.js code, but we are encountering difficulties in retrieving all the account details associated with the owner's email.

  1. we created service account to authenticate google account using the service account keys
  2. Getting only 1 account information unauthorized

'''node.js

 const key = require("./serviceAccountJson.json");

app.get ('/auth', async (req, res) => {
try {
const jwtClient = new google.auth.JWT(
key.client_email,
null,
key.private_key,
['https://www.googleapis.com/auth/business.manage']
);
console.log("jwtClient,",jwtClient)
jwtClient.authorize((err, tokens) => {
if (err) {
    console.error('Error while authenticating:', err);
    return;
}
console.log("tokens",tokens)
// Use the access token for API requests
const accessToken = tokens.access_token;
console.log('Access token:', accessToken);
res.send({accessToken:accessToken})
});
console.log(utils)
} catch (error) {
res.sendStatus (500);
console.log (error);
}
});

In the client id only 1 account information on the parent of client email we have multiple account . How we will get all accounts/location from the parent ?

1

There are 1 answers

0
vpgcloud On

Use the client library (https://github.com/googleapis/google-api-nodejs-client/tree/main/src/apis/mybusinessaccountmanagement) so you don't have to manage token management yourself.