Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Credential: This developer account does not own the application

I'm using Google client libraries and trying to make a GET request to Google Play API.

        GoogleCredential credential= new GoogleCredential.Builder().setTransport(netHttpTransport)
                .setJsonFactory(jacksonFactory)
                .setServiceAccountId(CLIENT_ID)
                .setServiceAccountScopes(SCOPE)
                .setServiceAccountPrivateKeyFromP12File(file)
                .build();
                credential.refreshToken();     
        HttpRequestFactory requestFactory =netHttpTransport.createRequestFactory(credential);
        GenericUrl url = new GenericUrl(URI);
        HttpRequest request = requestFactory.buildGetRequest(url);
        HttpResponse response = request.execute();

I get

 {
  "code" : 401,
  "errors" : [ {
    "domain" : "androidpublisher",
    "message" : "This developer account does not own the application.",
    "reason" : "developerDoesNotOwnApplication"
  } ],
  "message" : "This developer account does not own the application."
}

My app is unpublished, would that cause the problem?

like image 868
user1383845 Avatar asked Jun 10 '12 07:06

user1383845


3 Answers

I've got the same problem. It occurs because you authorize user in Google API who does not own the application and try to get data that belong to your app.

In this topic it is well described. http://support.google.com/googleplay/android-developer/bin/answer.py?hl=en&answer=2528691&topic=16285&ctx=topic

You should authorize by OAuth2 the owner of application, and then use Google API with obtained token.

like image 191
ikryvorotenko Avatar answered Nov 12 '22 20:11

ikryvorotenko


The problem is you are using the Service accounts OAuth 2.0 flow to authorize to the android-publisher API. I was doing it the same way. However, Google requires to use the Web server applications flow, which is ridiculous, since a human interaction is needed to allow for the API access.

Fortunately there is a way around it. You just have to obtain the refresh_token, store that and keep using it for future API calls. I wrote about it in more detail on my blog.

like image 24
Milan Cermak Avatar answered Nov 12 '22 20:11

Milan Cermak


We also struggled with this problem as we wanted to validate a purchase on our servers in order to unlock certain features. We tried multiple solutions and frameworks, written by fellow community users and even official implementations but none worked.

Turns out all we had to do was renew our OAuth token (which we just created) and then it all started working.

like image 45
Johan Avatar answered Nov 12 '22 21:11

Johan