I'm trying to use a service account to retrieve locations/reviews using the Google My Business API.
So far I have:
- Created a project in Developers Console
- Enabled access to the Google My Business API (it's been approved/whitelisted by Google)
- Created a service account with an associated OAuth identity
- Invited the OAuth identity (i.e. service account) as a manager for the Google My Business location
I am able to see the invitation when programmatically listing invites from https://mybusiness.googleapis.com/v4/accounts/[ACCOUNT NAME]/invitations using Google's sample .NET client available for download from https://developers.google.com/my-business/samples
However, when I try to accept the invitation through https://mybusiness.googleapis.com/v4/accounts/[ACCOUNT NAME]/invitations/[INVITATION NAME]:accept the request fails with a 500 server error.
When creating the MyBusinessService instance, I first create a service account credential like:
ServiceAccountCredential credential;
using (Stream stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read, FileShare.Read))
{
credential = (ServiceAccountCredential)GoogleCredential
.FromStream(stream)
.CreateScoped(new [] { "https://www.googleapis.com/auth/plus.business.manage" })
.UnderlyingCredential;
}
Next I create an initializer like:
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "My GMB API Client",
GZipEnabled = true,
};
Finally I create a MyBusinessService instance like: var service = new MyBusinessService(initializer);
I can list invitations with:
service.Accounts
.Invitations
.List("[ACCOUNT NAME]")
.Execute()
.Invitations;
However, trying to accept an invitation fails:
service.Accounts
.Invitations
.Accept(null, "[INVITATION NAME]")
.Execute();
The first parameter is null as this documentation states that the request body should be empty.
Or is there perhaps some other way to accept the invitation in order to enable the service account to retrieve Google My Business reviews for our location(s)?