我已经通过 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+ 个人资料。