是否可以使用服务帐户访问 Google Play 游戏服务 API?

2024-03-03

我已经通过 Google Play 开发者控制台创建了游戏(它是ready for testing,但尚未发布)。

在那里添加了两个服务帐户作为测试人员 -[email protected] /cdn-cgi/l/email-protection(Google App Engine 服务帐户)和6443621234[email protected] /cdn-cgi/l/email-protection(手动创建的服务帐户,它是在授予 Google Play 游戏服务 API 访问权限之前创建的)。第一个用于生产 GAE 环境,第二个用于开发环境(运行--appidentity_email_address)。这两个帐户都可以很好地与 Google Analytics API 配合使用。

现在我尝试使用这些帐户来使用 Google Play 游戏服务 API。

以下代码用于授权并且工作正常:

credentials = AppAssertionCredentials(scope=['https://www.googleapis.com/auth/games', 'https://www.googleapis.com/auth/plus.login'])
http = credentials.authorize(httplib2.Http(memcache))

但在尝试访问成就定义时出现错误(也尝试获取应用程序元数据 - 遇到同样的问题):

response = service.achievementDefinitions().list().execute()

在开发环境中我得到

<HttpError 404 when requesting https://www.googleapis.com/games/v1/achievements?alt=json returned "The requested application with ID 64436212345 was not found.">

并在生产中:

<HttpError 500 when requesting https://www.googleapis.com/games/v1/achievements?alt=json returned "">

有什么问题吗? Google Play Services API 支持服务帐户吗?

Upd.进一步分析发现,64436212345是我的GAE应用程序的ID,而我的Google Play应用程序的ID是760943112345。

因此,我转到 Google Developer Console 查找应用程序 760943112345 并添加6443621234[email protected] /cdn-cgi/l/email-protection and [email protected] /cdn-cgi/l/email-protection作为他们的成员。这没有帮助。

然后我在那里生成了新的服务帐户 ID,并使用该服务帐户在本地运行 GAE。结果,我开始得到

<HttpError 401 when requesting https://www.googleapis.com/games/v1/applications/760943112345?alt=json returned "User has not completed registration.">

当然,我的服务帐户没有 Google+ 个人资料。


我也在服务帐户和 Google 游戏服务方面遇到了困难,并且陷入了同一点(我的服务帐户没有 G+ 帐户)。

我在其中找到的唯一指示谷歌文献 https://code.google.com/p/google-api-php-client/wiki/OAuth2#Service_Accounts(据说更新于 2014 年 1 月 22 日)说服务帐户是not支持的:

Warning:目前很少有 Google API 支持服务帐户。目前,以下 Google 开发者服务支持服务帐户:

  • 谷歌云存储
  • 谷歌预测API
  • 谷歌网址缩短器
  • 谷歌 OAuth 2.0 授权服务器
  • 谷歌大查询

然而,这是嵌入在一些 google api php 客户端文档中的,所以我无法证明它的有效性。

如果您有幸让它发挥作用,请告诉我,我也会这样做!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以使用服务帐户访问 Google Play 游戏服务 API? 的相关文章

随机推荐