It is possible to access the Google Play Developer API using Service Account flow.
Official sample shows how to authorize with Service Account using service account email
and p12 file
.
The relevant credential creating code looks as following:
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;
}
Folks at AzimoLabs wrote a post where they retrieving store reviews using this method. They also open-sourced their tool.
You can also authorize with Service Account using JSON key type:
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));
}
}
More detailed instructions can be found here.