While sending back response to google business messages api, we are facing this exception.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Your partner account doesn't have access to this conversation.", "reason" : "forbidden" } ], "message" : "Your partner account doesn't have access to this conversation.", "status" : "PERMISSION_DENIED" }
Please help if someone has faced similar issues, we have enabled the google business messages api for our project and we are using the proper service account credentials to send back the response.
Hello yashgadhiya,
There is a same concern in StackOverflow, and as per Leonardo Tanoue:
"
I found out what I was doing wrong. In the OAuth 2.0 Playground, there's a settings button where you need to enter your application's Client ID and Secret; I did that the first time forgot every time after that; so I was using some default Application for testing instead of my own. After adding those two I kept working and found out that I had the wrong location ID. The correct way to get your location ID is once you are a manager of a Business Location you need to go to the Location Manager page on Google and find the Business Profile ID under Advanced Settings. Don't use the Google Maps tool to get the location ID for Google Maps those are different IDs!
EDIT 01/19/2023
I was able to get the Google API to work with my request in C# code!
using Google.Apis.Auth.OAuth2;
using Google.Apis.MyBusinessAccountManagement.v1;
using Google.Apis.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
HttpClient client = new HttpClient();
using IHost host = Host.CreateDefaultBuilder(args).Build();
var configuration = new ConfigurationBuilder().AddJsonFile($"appsettings.json", optional: false, reloadOnChange: true);
var config = configuration.Build();
Console.WriteLine($"Hello, World! You are in the {config.GetValue<string>("General:Environment")} Environment");
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.FromStream(stream).Secrets,
new[] { "https://www.googleapis.com/auth/business.manage" },
"user", CancellationToken.None);
}
var service = new MyBusinessAccountManagementService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "{ProjectName}",
ApiKey = "{API Key}"
});
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://mybusiness.googleapis.com/v4/accounts/{accountid}/locations/{locationid}/reviews");
var response = await service.HttpClient.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();
Console.WriteLine(json);
// API call to get Accounts
// var accounts = await service.Accounts.List().ExecuteAsync();
//Console.WriteLine(accounts.ToString());
Console.ReadLine();
await host.RunAsync();
"