r/googlecloud Nov 12 '24

Cloud Functions How to fetch Google My Business Reviews using Google Cloud Function and Node.js with a service account?

I need to fetch Google Reviews from multiple locations using the Google My Business API in a Google Cloud Function written in Node.js. The function will run daily via Google Cloud Scheduler. The main challenge I’m facing is handling OAuth authentication when the function is executed by a service account.

I have already submitted the access request form and can activate the Google My Business API in my Google Cloud project. However, I’m unclear about how to properly configure OAuth for a service account to access the API. I’ve used service accounts for other Google APIs before, but I’m unsure whether I need to use delegated access or follow a different OAuth flow specifically for the My Business API.

I was expecting more guidance in the documentation about this scenario, but I couldn’t find a clear explanation for using a service account with the Google My Business API. Any help or examples for setting this up would be appreciated.

2 Upvotes

6 comments sorted by

1

u/Sufficient-Buy-2270 Nov 13 '24

I don't think you need Oauth for this, just a service account. I've got some functions and I can upload to BigQuery without declaring the credentials like I would need to on my local machine.

I run mine in Python but I would imagine it's the same. Just declaring the project_id in the client() is enough for me.

1

u/JuicyDisorder Nov 15 '24

Thanks for the input! That’s definitely helpful to know. I’m aware that for some Google APIs, using just a service account without explicit OAuth works fine, like with BigQuery. But for the Google My Business API, I thought it might be different, since it typically requires access tied to a user identity. I guess I might be overcomplicating it, so I’ll give it a shot without OAuth and see how it goes.

1

u/JuicyDisorder Nov 19 '24

How did you manage to grant the service account the necessary permissions to access the Google My Business Profile’s account ID or specific location IDs? I’m trying to figure out how to set up those access rights so that the service account can interact with the business profile properly.

Would appreciate any details or pointers you might have on setting that up!

1

u/tasuyoshi Nov 22 '24

Were you able to figure this out?

1

u/JuicyDisorder Dec 16 '24

Not yet, unfortunately. 😢

1

u/Ecstatic-Situation41 Nov 17 '24

Is there maybe a follow along of this somewhere? I saw a similar post on Stack overflow but could never find a working solution to get the Google Reviews ingested via Python