I want to verify an Android IAP via Google's API on my central game server.
There is a lot of partial information about this and it is blowing my mind. I have not paid €25 to become a Google Developer, because I am not sure if I will be able to get it to work.
When an IAP is made, a JSON object is returned. This object contains several fields, like the purchaseToken
and the productId
(source).
I found that you can request information about a bought product via the following GET request: GET https://www.googleapis.com/androidpublisher/v2/applications/packageName/purchases/products/productId/tokens/token
.
I could program this no problem, but you need to authorize yourself: "This request requires authorization with the following scope" (source). This is where I started getting confused.
- You need to create some sort of login token via the Dev Console (Link). I don't know what type. OAuth or service account?
- This token is short lived. You need to refresh it
There are several huge code snippets to be found on the internet that may or may not work, but they are all partial and not very well documented.
I found Googles API library for Java: link. This API seems to be made to fix all these problems with OAuth and tokens for you. However, I am unable to figure out how to get this API to work.
It is probably not that hard, but there are a lot of different ways to do it, and I can't find any clear examples.
TL;DR: I need to verify a Google Play IAP serverside. To do this, I want to use Googles Java API.
EDIT: THIS MIGHT BE A WAY SIMPLER SOLUTION. Passing the original JSON plus the JSON to the server might be way easier, because I could just verify the asymmetric signature server side.