是否可以通过服务帐户访问Google Play游戏服务API? [英] Is it possible to access Google Play Game Services API with service account?

查看:176
本文介绍了是否可以通过服务帐户访问Google Play游戏服务API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过Google Play开发者控制台创建了游戏(已准备好进行测试,但尚未发布)。

两个服务帐户作为测试人员添加 - 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))

但是在尝试访问成就定义时出现错误(也尝试获取应用程序元数据 - 得到)
$ b

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


$ b

在开发环境中,我得到

 < HttpError 404请求https://www.googleapis.com/games/v1/achievements?alt=json时返回未找到所需的ID为64436212345的应用程序。> 

在制作中:

 <请求https://www.googleapis.com/games/v1/achievements?alt=json返回的HttpError 500> 

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



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



因此,我去了Google Developer Console,申请了760943112345,并添加了 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc@developer.gserviceaccount。 com myappid@appspot.gserviceaccount.com 作为其成员。它没有帮助。


然后,我在那里生成新的服务帐户ID,并使用此服务帐户在本地运行GAE。结果,我在请求https://www.googleapis.com/games时已开始获得

 < HttpError 401 / v1 / applications / 760943112345?alt = json返回用户未完成注册。> 

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

解决方案

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



我在谷歌资料(假设2014年1月22日更新)表示服务帐户不支持:

< blockquote>

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




  • Google云端存储

  • Google预测API

  • Google URL Shortener

  • Google OAuth 2.0授权服务器

  • Google BigQuery
  • $

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



    让我知道你是否有幸运用此功能,我也会这么做!


    I've created the game thru Google Play Developer Console (it is ready for testing, but not published yet).

    Two service accounts are added there as testers - myappid@appspot.gserviceaccount.com (Google App Engine service account) and 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc@developer.gserviceaccount.com (manually created service account, it was created before an access to Google Play Game Services API was given). First one is used for production GAE environment, second one is for development environment (run with --appidentity_email_address). Both accounts work well with Google Analytics API.

    Now I try to use these accounts to work with Google Play Game Services API.

    The following code is used for authorization and works fine:

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

    But I am getting an error when trying to access achievements definition (also tried to get application metadata - got the same issue):

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

    In development environment I get

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

    and in production:

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

    What is wrong there? Are service accounts supported by Google Play Services API?

    Upd. Further analysis showed that 64436212345 is an ID of my GAE application, when an ID of my Google Play application is 760943112345.

    So, I went to Google Developer Console for application 760943112345 and added 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc@developer.gserviceaccount.com and myappid@appspot.gserviceaccount.com as the member their. It didn't help.

    Then I generated new service account ID there and run GAE locally with this service account. In result, I've started to get

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

    Of course, my service account doesn't have Google+ profile.

    解决方案

    I am also struggling with service accounts and Google game services, and am stuck at the same point (my service account doesn't have a G+ account).

    The only indication I have found in the Google literature (supposedly Updated Jan 22, 2014) says service accounts are not supported:

    Warning: Very few Google APIs currently support Service Accounts. Service accounts are >currently supported by the following Google developer services:

    • Google Cloud Storage
    • Google Prediction API
    • Google URL Shortener
    • Google OAuth 2.0 Authorization Server
    • Google BigQuery

    This is embedded in some google api php client documentation however, so I cannot attest its validity.

    Let me know if you have any luck getting this to work and I'll do the same!

    这篇关于是否可以通过服务帐户访问Google Play游戏服务API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆