是否可以使用服务帐户流访问Google Play Developer API?此处的文档(https://developers.google.com/android-publisher/authorization)仅提及OAuth 2.0 Web服务器流程.但目前还不清楚它是示例还是限制.
如果可能的话,提供一些工作示例链接会很棒.因为我无法通过"此开发者帐户不拥有应用程序"响应.
可以使用服务帐户流程访问Google Play 开发者 API。
官方示例展示了如何使用service account email和向服务帐户进行授权p12 file。
相关凭证创建代码如下所示:
private static Credential authorizeWithServiceAccount(String serviceAccountEmail)
throws GeneralSecurityException, IOException {
log.info(String.format("Authorizing using Service Account: %s", serviceAccountEmail));
// Build service account credential.
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(new File(SRC_RESOURCES_KEY_P12))
.build();
return credential;
}
Run Code Online (Sandbox Code Playgroud)
AzimoLabs 的人们写了一篇文章,他们使用这种方法检索商店评论。他们还开源了他们的工具。
您还可以使用 JSON 密钥类型向服务帐户进行授权:
private static Credential authorizeWithServiceAccount() throws IOException {
log.info("Authorizing using Service Account");
try (FileInputStream fileInputStream = new FileInputStream(JSON_PATH)) {
return GoogleCredential.fromStream(fileInputStream, HTTP_TRANSPORT, JSON_FACTORY)
.createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER));
}
}
Run Code Online (Sandbox Code Playgroud)
可以在此处找到更详细的说明。
| 归档时间: |
|
| 查看次数: |
478 次 |
| 最近记录: |