首页 文章

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

提问于
浏览
2

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

作为测试人员添加了两个服务帐户 - myappid@appspot.gserviceaccount.com (Google App Engine服务帐户)和 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc@developer.gserviceaccount.com (手动创建的服务帐户,它是在访问Google Play游戏服务API之前创建的) . 第一个用于 生产环境 GAE环境,第二个用于开发环境(用 --appidentity_email_address 运行) . 这两个帐户都适用于Google AnalyticsAPI .

现在,我尝试使用这些帐户来使用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. 进一步分析显示,当我的Google Play应用程序的ID为760943112345时,64436212345是我的GAE应用程序的ID .

因此,我访问了Google Developer Console以获取应用程序760943112345,并添加了 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc@developer.gserviceaccount.commyappid@appspot.gserviceaccount.com 作为其成员 . 它没有帮助 .

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

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

当然,我的服务帐户没有Google Profiles .

2 回答

  • 2

    我也在努力处理服务帐户和谷歌游戏服务,并且陷入同一点(我的服务帐户没有G帐户) .

    我在Google literature(据称2014年1月22日更新)中找到的唯一指示是服务帐户支持: not

    警告:目前很少有Google API支持服务帐户 . 以下Google开发人员服务目前支持服务帐户:Google Cloud 端存储Google预测API Google URL缩短器Google OAuth 2.0授权服务器Google BigQuery

    这是嵌入在一些谷歌api php客户端文档,但所以我无法证明其有效性 .

    如果你有运气让我知道,我也会这样做!

  • 1

    编辑:这是实际的答案:你 have 创建 another API project 并将其链接到你的游戏项目,如Getting Started with the Google Play Games Services Publishing API中所述 . 您添加到游戏中的服务帐户's project won' t工作 . 此外,您必须通过Google Play Developer Console添加此新API项目,而不是通过Google Developers Console . 据我记忆,你去后者才能得到你的钥匙 . 整个局面让我永远想通了 .


    我保留以下文字以供将来参考:

    编辑:我写了下面的答案,认为你没有谈论发布API . 但你似乎是 . 或者它的早期版本 . 我希望以下答案对于希望通过服务帐户访问Management API的人有用:

    我一直在努力,并得出结论,服务帐户不适用于GPGS Management API,后者是处理成就和事物的API . 以下是我用来得出这个结论的事实:

    提及服务帐户的GPGS文档中的

    如果这在GPGS文档中更清晰一点,那就太好了 . 他们从GPGS页面链接的通用Google Cloud文档让我相信服务帐户会起作用 .

相关问题