Search code examples
google-apiin-app-purchasejwtgoogle-oauthin-app-billing

How to get access to Google Androidpublisher API using JWT?


So there is a way to authorize on Google API services using JWT tokens described here: Service account authorization without OAuth.

I've tried to follow this instruction:

1. Create a service account. Be sure to keep the JSON file you get when you create the account.

Done.

2. Get the API's service name and API name from the service definition file on GitHub.

I went to Google APIs GitHub repository and started searching. I need to get access to Androidpublisher API. So, at first i've tried to examine the folders structure and underestand where the required API is. No luck. Then i've tried to search the whole repo for *.yaml files by keywords "androidpublisher" and "android". No luck again. I've actually found something by keyword "publisher": it was pubsub API, but it seems that it's not what i'm looking for.

Ok let's read that again:

If the API you want to call has a service definition published in the Google APIs GitHub repository, you can make authorized API calls using a JWT instead of an access token.

So basically it means that any API may or may not be published there.

In this SO question i've found a way to authorize for Androidpublisher API using JSON file with credentials and Java client library for Google Play Developer API:

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));
    }
}

So i assume that there is a way to authorize there using JWT tokens. But i can't use Java library, because my service will run on C++. And unfortunately Google didn't provide a library for C++ developers.

At one point i was so desperate that i've even tried to compile this code on Java and run it just to see WHERE it is sending its HTTP requests to (using debugger or Wireshark). But i'm not a Java developer and after a hour of resolving a dependencies issues i've still had some problems with "missing Java Key Store" (or something like that) while running the code. So i gave up.

So my final question is: what are the Service name and API name for Androidpublisher API?

I should have been able to retrieve those values in the second step of this instruction. But i failed. I feel like that is the only piece of information i'm missing right now to complete my task.


Solution

  • I found a way to access Adndoidpublisher API without following step:

    2. Get the API's service name and API name from the service definition file on GitHub.

    I can create a JWT token and then use it to obtain an API access token. The way of doing this is described here in HTTP/REST tab.

    Then i can just access the API in the ordinary way.