user test
Introduction
This document provides information on how to export pricing set up in Google Play using one of two methods:
- Exporting a price CSV
- Google’s developer API
The methods covered in this document will eventually generate a JSON file which can be used to instruct Flexion on how to price your game.
We outline two methods due to the CSV export not always providing full pricing. More specifically – if price templates are used, the CSV export will not provide local pricing information. Hence we also provide information on how to use Google’s Developer API to export prices. This method does provide a full pricing export.
CSV export
For exporting pricing out of the Google Play, follow these steps.
- Select the App
- Navigate to the In-app products page (Monetise > Products > In-app products
- At the top on the right-hand side there will be an Export button
- The export will generate a CSV which contains your full set of configured items and associated pricing
Google Developer API export
The Google Play developer API can be used to export (and set) all pricing for your game in Google Play. The export results in a JSON file that Flexion can ingest to configure pricing in Flexion’s channels.
This guide covers two key areas:
- Using the developer API to extract and export configured pricing
- Setting up the Google Play developer console for API access (if not done already)
Note: the Google Play developer API provides read AND write access to your developer account. This guide provides an overview on how to export pricing. Depending on the solution you use to access your developer account through the developer API you may end up having the ability to export pricing as well as to set pricing and/or add or remove in-app items. You acknowledge that Flexion cannot be held responsible for any issues relating to your pricing in Google Play which may arise from you implementing methods outlined in this guide. It is strongly recommended that the steps outlined here are tested in a safe environment – e.g. a test account – prior to implementing them against your live Google Play account or games.
Using the developer API to extract and export configured pricing
The Developer API for in-app item prices is a simple CRUD API.
Base Endpoint:
<https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/inappproducts>
Note: packageName is the game’s original package name.
Allowed methods:https://developers.google.com/android-publisher/api-ref/rest/v3/inappproducts
There are 4 methods to call the API:
- cURL
- HTTP
- Javascript
- Java
Regardless of the method of calling the API, you will have to make two HTTP requests, one for requesting the OAuth access token to access the API and one for requesting the item details.
What you will need
To get item details you will need the following:
• Package name of the game
• API key
• OAuth client ID
• OAuth client secret
Getting item details
There are two steps to get item details:
- request OAuth access token
- request the item details from the API
Request OAuth access token
There are two steps to get the access token.
- Request authentication code by logging in with your Google account
- Open this URL in a browser, where YOUR_CLIENT_ID is the OAuth Client ID: https://accounts.google.com/o/oauth2/v2/auth?client_id=YOUR_CLIENT_ID&response_type=code&scope=https://www.googleapis.com/auth/androidpublisher&access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:oob
- Log into your account and authorize the request
- Copy the authentication code Google generated
- Request access token
- Send a POST request to the OAuth service, you will need to send multiple parameters via the request body in URLencoded form data format (e.g.: parameter1=value1¶meter2=value2)
- Copy the access token from the response
| Request Details | |
|---|---|
| Method details | POST |
| IRÉ | https://www.googleapis.com/oauth2/v4/token |
| Headers | |
|---|---|
| Content-type | application/x-www-form-urlencoded |
| Parameters | |
|---|---|
| client_id | YOUR_CLIENT_ID |
| client_secret | YOUR_CLIENT_SECRET |
| code | Authentication code from step 1 |
| redirect_uri | urn:ietf:wg:oauth:2.0:oob |
| grant_type | authorization_code |
Request item details
Send a GET request to the Google Developer API to get the item details
| Headers | |
|---|---|
| Authorization | Bearer ACCESS_TOKEN |
| Accept | application/json |
Methods to call the API
cURL
curl \
'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/[PACKAGENAME]/inappproducts?key=[YOUR_API_KEY]' --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' --header 'Accept: application/json' --compressed
[PACKAGENAME] - game’s original package name
[YOUR_API_KEY] - API key generated by the game’s developer
[YOUR_ACCESS_TOKEN] - access token requested manually from the OAuth service, see https://www.jhanley.com/google-oauth-2-0-testing-with-curl/
HTTP
GET https://androidpublisher.googleapis.com/androidpublisher/v3/applications/[PACKAGENAME]/inappproducts?key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN] Accept: application/json
[PACKAGENAME] - game’s original package name
[YOUR_API_KEY] - API key generated by the game’s developer
[YOUR_ACCESS_TOKEN] - access token requested manually from the OAuth service, see https://www.jhanley.com/google-oauth-2-0-testing-with-curl/
Note: using HTTP to call the API allows you to get the pricing details from Google without any software development. This can be achieved through calling the API from a browser using a plugin which can add or modify required HTTP headers.
Javascript
`
/`
function authenticate() { return gapi.auth2.getAuthInstance() .signIn({scope: "https://www.googleapis.com/auth/androidpublisher"}) .then(function() { console.log("Sign-in successful"); }, function(err) { console.error("Error signing in", err); }); } function loadClient() { gapi.client.setApiKey("YOUR_API_KEY"); return gapi.client.load("https://androidpublisher.googleapis.com/$discovery/rest?version=v3") .then(function() { console.log("GAPI client loaded for API"); }, function(err) { console.error("Error loading GAPI client for API", err); }); }
// Make sure the client is loaded and sign-in is complete before calling this method.
function execute() {
return gapi.client.androidpublisher.inappproducts.list({ "packageName": "PACKAGE_NAME" }) .then(function(response) { // Handle the results here (response.result has the parsed body). console.log("Response", response); }, function(err) { console.error("Execute error", err); }); } gapi.load("client:auth2", function() { gapi.auth2.init({client_id: "YOUR_CLIENT_ID"}); }); </script>
<button onclick="authenticate().then(loadClient)">authorize and load</button> <button onclick="execute()">execute</button>
YOUR_API_KEY - API key generated by the game’s developer
PACKAGE_NAME - game’s original package name
YOUR_CLIENT_ID - OAuth client ID generated by the game’s developer
Java
Google has a Java library for their Developer API, which works similarly to javascript.
Setting up the Google Play developer console for API access
Follow the below steps to get the Google Play developer console configured to allow API access for pricing management. Note – the access created is read and write – hence, pay special attention to
HOW TO GENERATE API CREDENTIALS
Follow the below steps in order to generate your API credentials
- Go to https://play.google.com/console
- Select API Access in the Setup section
Google Cloud Project not yet linked
- Link existing project
- Select Link existing project
- Select your Google Cloud project from the dropdown list
- Create new project
- Select Create new project
- Click Link project
Google Cloud Project already linked
- View project
- Go to APIs and Services
- Enable API
- Click + ENABLE APIS AND SERVICES
- Search for Google Play Android Developer API
- Select first match.
- Click Enable if it’s not already enabled.
- Create API key
- Go to Credentials
- Click + CREATE CREDENTIALS
- Select API Key
- Click Save
- Create OAuth Client
- Click + CREATE CREDENTIALS
- Select OAuth client ID
- Make the following changes
- Application type >>> Desktop Application
- Name >>> Can be whatever name you want
- Click Create
Flexion Mobile Plc. 2024. All Rights Reserved
| Confidential |
Updated about 1 year ago
