I want to use a Google My Business API to search and manage the businesses of our clients using my organization account detail.
I want to use API as an Agency as I want to manage our clients' businesses.
I've submitted the API access form and got confirmation to use the APIs. Also, I've generated the OAuth credentials and service-account in the same account.
But as per the GMB API document, we need to pass an access token in order to access an API.
I've reviewed the authentication process using OAuth and service accounts. As per my requirement, I want to generate access token at the back end side directly from my NodeJS server code without user interaction.
I want to use my account detail to use APIs so need to get permission from the user as I do not need any user information.
I've tried the following for use as a service-account but it returns an error.
const keys = require("./config/gmb.json");
const {OAuth2Client,GoogleAuth,JWT} = require('google-auth-library');
const client = new JWT({
email: keys.client_email,
key: keys.private_key,
scopes: ['https://www.googleapis.com/auth/business.manage'],
});
console.log(client.credentials); // It returns refresh_token=jwt-placeholder, expiry_date=1
const tokenInfo = await client.getTokenInfo(client.credentials.access_token); // It returns Error: invalid_token
So anyone has an idea on this. Your help will appreciatable.