Is it possible to get access to Google Play Developer API using Service Account flow? Documentation here (https://developers.google.com/android-publisher/authorization) mentions only OAuth 2.0 Web Server flow. But it's unclear whether it is example or restriction.
If it is possible it will be great for some link to working example to be provided. Cause I wasn't able to get past "This developer account does not own the application" response.
Navigate to “IAM & Admin” and there to “Service Accounts”, if this view is not already open. The title should show “Service accounts for project Google Play Android Developer”. Here you'll see other service accounts if you already have some in place.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With