Google api 以编程方式接受服务帐户的Google My Business邀请
我正试图使用一个服务帐户来检索位置/评论使用谷歌我的业务API 到目前为止,我已经:Google api 以编程方式接受服务帐户的Google My Business邀请,google-api,google-api-dotnet-client,google-my-business-api,Google Api,Google Api Dotnet Client,Google My Business Api,我正试图使用一个服务帐户来检索位置/评论使用谷歌我的业务API 到目前为止,我已经: 在开发者控制台中创建了一个项目 启用对Google My Business API的访问(该API已被Google批准/列入白名单) 创建了具有关联OAuth标识的服务帐户 邀请OAuth身份(即服务帐户)作为Google My Business location的经理 当以编程方式列出来自https://mybusiness.googleapis.com/v4/accounts/[帐户名]/investmen
https://mybusiness.googleapis.com/v4/accounts/[帐户名]/investments
使用谷歌的.NET客户端示例,可从下载
但是,当我试图通过https://mybusiness.googleapis.com/v4/accounts/[帐户名]/investments/[邀请名]:接受
请求失败,出现500服务器错误
创建MyBusinessService
实例时,我首先创建一个服务帐户凭据,如:
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;
}
接下来,我创建一个初始值设定项,如:
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "My GMB API Client",
GZipEnabled = true,
};
最后,我创建了一个MyBusinessService
实例,比如:var service=newmybusinessservice(初始值设定项)代码>
我可以通过以下方式列出邀请:
service.Accounts
.Invitations
.List("[ACCOUNT NAME]")
.Execute()
.Invitations;
但是,尝试接受邀请失败:
service.Accounts
.Invitations
.Accept(null, "[INVITATION NAME]")
.Execute();
第一个参数是null
,表示请求正文应该为空
或者是否有其他方式接受邀请,以使服务帐户能够检索我们所在地的Google My Business reviews?GMB API中的服务帐户不能替代Google用户帐户身份验证。您需要将Oauth与用户帐户(例如,可以访问GMB web界面的gmail帐户)一起使用,以便您可以代表用户执行操作。这方面没有进展吗?Google正式允许通过服务帐户使用OAuth进行服务器到服务器的通信:我们需要通过编程方式在Google上获得我们业务的评论评级。一切都正常,但我们仍无法接受服务帐户上的邀请。