【问题标题】:Is it possible to access Google Play Game Services API with service account?是否可以使用服务帐户访问 Google Play 游戏服务 API?
【发布时间】:2014-05-30 09:40:18
【问题描述】:

我通过 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 Analytics API 配合使用。

现在我尝试使用这些帐户来使用 Google Play Game Services 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 是否支持服务帐号?

更新。进一步分析表明,64436212345是我的GAE应用的ID,而我的Google Play应用的ID是760943112345。

因此,我前往 Google Developer Console 获取应用程序 760943112345,并将 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc@developer.gserviceaccount.commyappid@appspot.gserviceaccount.com 添加为他们的成员。它没有帮助。

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

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

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

【问题讨论】:

    标签: google-app-engine google-api google-play-services google-play-games


    【解决方案1】:

    我也在为服务帐户和 Google 游戏服务而苦恼,并且卡在同一点上(我的服务帐户没有 G+ 帐户)。

    我在Google literature(预计于 2014 年 1 月 22 日更新)中发现的唯一指示是支持服务帐户:

    警告:目前很少有 Google API 支持服务帐户。服务帐号>目前受以下 Google 开发者服务支持:

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

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

    如果你有任何运气让这个工作,请告诉我,我也会这样做!

    【讨论】:

    • 好像已经快两年了,但是如果您仍然想知道,请看下面我的回答:D欢呼。
    【解决方案2】:

    编辑:这是实际答案: 您必须创建另一个 API 项目并将其链接到您的游戏项目,如 Getting Started with the Google Play Games Services Publishing API 中所述。您添加到游戏项目的服务帐户将不起作用。此外,您必须通过Google Play Developer Console 添加这个新的API 项目,而不是通过Google Developers Console。据我记得,你去后者只是为了得到你的钥匙。这整个情况让我永远想通了。


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

    编辑:我在下面写了答案,以为您没有谈论发布 API。但你似乎是。或者它的早期版本。我希望以下答案对希望使用服务帐户访问管理 API 的人有用:

    我遇到了同样的问题,并得出结论认为服务帐户不适用于 GPGS 管理 API,这是处理成就和此类事情的 API。以下是我用来得出这个结论的事实:

    如果这在 GPGS 文档中能更清楚一点就更好了。他们从 GPGS 页面链接的通用 Google Cloud 文档让我相信服务帐户可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-06
      • 2014-01-19
      • 2012-10-08
      • 1970-01-01
      • 2014-02-02
      • 2019-02-03
      • 1970-01-01
      相关资源
      最近更新 更多