Question

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.

Was it helpful?

Solution

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!

OTHER TIPS

Edit: here is the actual answer: You have to create another API project and link it to your game's project, as explained in Getting Started with the Google Play Games Services Publishing API. The service accounts that you add to your game's project won't work. Also, you have to add this new API project through Google Play Developer Console, and not through Google Developers Console. As far as I remember, you go to the latter to get your key only. This whole situation took me forever to figure out.


I'm keeping the below text for future reference:

Edit: I wrote the answer below, thinking that you did not talk about the Publishing API. But you are, it seems. Or an earlier version of it. I hope the below answer will be useful for people looking to access Management API with a service account:

I struggled with the same and concluded that service accounts do not work with the GPGS Management API, which is the API that deals with achievements and things of that sort. Here are the facts that I used to reach this conclusion:

  • The only place in GPGS docs that service accounts are mentioned is the Publishing API.
  • Management API Docs contains descriptions for each function about the authorization requirements such as: "This method is only available to user accounts for your developer console.", while Publishing API Docs have no such descriptions.
  • The sample app for Management API does not use a service account.

It would be nice if this was a bit clearer in the GPGS docs. The generic Google Cloud docs that they link from GPGS pages made me believe that service accounts would work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top