我正在使用Google客户端库并尝试向Google Play API发出GET
个请求。
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();
我得到了
{
"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."
}
我的应用未发布,会导致问题吗?
答案 0 :(得分:6)
我遇到了同样的问题。之所以出现这种情况,是因为您授权Google API中的用户不拥有该应用,并尝试获取属于您应用的数据。
在这个主题中,它有很好的描述。 http://support.google.com/googleplay/android-developer/bin/answer.py?hl=en&answer=2528691&topic=16285&ctx=topic
您应该通过OAuth2授权应用程序的所有者,然后使用Google API获取令牌。
答案 1 :(得分:4)
问题是您使用服务帐户OAuth 2.0流程来授权android-publisher API。我也是这样做的。但是,Google需要使用Web服务器应用程序流,这很荒谬,因为需要人工交互才能进行API访问。
幸运的是,有一种解决方法。您只需获取refresh_token,将其存储并继续使用它以用于将来的API调用。我在我的博客上wrote about it in more detail。
答案 2 :(得分:1)
我们也在努力解决这个问题,因为我们想在我们的服务器上验证购买以解锁某些功能。我们尝试了多个解决方案和框架,由社区用户编写,甚至是官方实施,但都没有。
原则上我们所要做的就是更新我们的OAuth令牌(我们刚刚创建),然后它们全部开始工作。
答案 3 :(得分:0)
我怀疑问题恰恰在于发布。您首先需要将应用程序绑定到(开发人员)帐户,然后您将收到CLIENT_ID和其他凭据(例如密钥等)。