B4J Tutorial Google Play Developer API

Google Play Developer API allows you to access your developer account and do all kinds of things. For example get the latest app reviews or check the status of in-app purchases.

Like with all other Google services, we will use GoogleOAuth2 class for authentication: https://www.b4x.com/android/forum/threads/79426/#content

This example is made of two projects:

1. A UI project that is used for the first authentication. Note that it doesn't show any form.
2. A server project that uses the token created in the first step to access the inventory API. The inventory API is just used as an example. It should be simple to change it to other APIs.

- The first step is to link a project in Google Play developer console:

SS-2017-07-19_14.41.22.png


In this project you need to create new credentials (type = other).
You need to get the client id and client secret.

Make sure that Google Play Android Developer API is enabled.

- Update ClientId and ClientSecret globals in the two projects.
- Update the package in the code and run it. The browser will open and you will be asked to authorize the app to access your developer account.
- If all goes well you will see a list of the available in-app products.
This will also create the token file that will be used by the server app

- Run the server app and test it with:
http://127.0.0.1:51042/inventory?package=your.package.here

You should see the json response:

SS-2017-07-19_14.47.42.png
 

Attachments

  • GooglePlayDeveloperServer.zip
    4.3 KB · Views: 732
  • GooglePlayDeveloperUI.zip
    3.7 KB · Views: 748
Top