Skip to main content

Google Play Developer API: How to Create a Service Account

Why am I reading this?

  • Mobile applications are surrounded by so many modules in addition to that, the IN-APP Purchase and Subscriptions play a good amount of role, where you as an owner of the app, can generate revenue by selling consumable and non-consumable goods such as Coins for Games, Subscription plans for your app many things.
  • Now, as you are selling some goods on your app, there must be a way to validate that purchase or get the details. But obviously, you can do it from the app itself as Google does provide SDK for the same. (SDK – Software Development Kit). But, we are living in a world where Android and iOS exist and in a very competitive market!
  • Google Play Developer API gives us the power to check the user’s transaction from the RESTful APIs which leads you to read this blog.
  • With the RESTful API, we can do this call from the BACKEND and leave the app standalone and do other stuff

Offering

Google Play Developer API lets you manage the two main components in your project
  • The Publishing API lets you upload and publish apps, and perform other publishing-related tasks.
  • The Subscription and IN-APP Purchase API lets you manage in-app purchases and subscriptions. [We are going to explore these APIs]

Objective

To verify the Google In-App Purchase and Subscriptions (IAP)

Requirements

  1. Google Play Developer Console Access
  2. Google Cloud Console Access
Note: To start making API calls, you will set up and manage the Google Play Developer API directly from the Google Play Console. The API can be managed by the owner of the Google Play Developer Account.

Tip: If you already have an existing project over Google Cloud Console then it should be using the same google account you used for the Google Play Console. If you have a different account setup then there are certain steps and roles with which we can achieve this.

Here are the main steps we are focusing on:
  1. Set up a new or existing Google Cloud Project
  2. Use a service account to access the Google Play Developer API
  3. Access the RESTful APIs for analyzing the app

Let’s Start

Linking your account and project

Before you can access the Google Play Developer API, you must link your Google Play Developer Account to a Google Cloud Project. In most cases, we recommend that you create a new Google Cloud Project dedicated to your Google Play Developer Account, but you can link an existing project. Keep in mind that each Google Play Developer Account can only be linked to a single Google Cloud Project. If you have multiple apps in the same Google Play Developer Account, they all must share the same Google Cloud Project.

Access Google Play Developer Console 

  1. Login to Google Play Developer Console Play Console (google.com)
  2. Select your account


  3. On the side avigation menu, select Setup>API Access


  4. Agree with API terms of services (Just follow the on-screen instructions if any)
  5. Once done, you will be seeing options to link your existing project or create a new project


Link Existing Project

If you already have a Google Cloud Project then you can Link that project or you can create a new project.


Select the existing project by clicking on Choose Project dropdown menu If your project isn’t listed, verify that your Google Play Console account is with the role OWNER and Google Play Developer API is enabled for the project. If not then you can do it quickly by following, how to do it?



After saving the project, You will be seeing a screenshot below. Now, we need to work on the Service Accounts section. If you already have a service account then you will be seeing it listed. If not then we will create a new service account. 

Create New Project

Select the option Create New Project and click the SAVE button


A new project will be created and you can see that project as listed. You can rename the project later on. 

Configure Service Accounts

Most common secure software service which will access the API.

Service accounts must be used in a secure environment, such as your server. The service account credentials need to be securely managed so they are not revealed to anyone that is not authorized to use the API.

Once we have the project linked or created, our main goal is to Create new Service Account or give access to an already created service account.

Create new service account


  1. Read the instruction once you click this button, “CREATE NEW SERVICE ACCOUNT” 

     
  2. Click on option #1, Go to the Google Cloud Platform and open that URL in the new tab
  3. Now, you are on the Google Console. 


  4. Click on "CREATE SERVICE ACCOUNT"
  5. Name your service account and provide the description. No need to alter the field, "Service account" which will be auto-generated based on the service account name you provide. 
  6. Click on "CREATE AND CONTINUE" to define ROLE in step 2. 



  7. Search for "Service Account Admin" and select it. 
  8. Click on the "CONTINUE"


  9.  Nothing to do on step 3, so just click the button "DONE"


  10.  Your service account has been created and listed on the same page. 


  11. Select the account and switch to KEYS tab. We are going to add key to this service account.

  12. Click on ADD KEY and select "Create new key"




  13. Select the "Key type" as JSON and click on the "CREATE" button
  14. The key will be created and will ask you to download it. Save the file as it is. We will need this for the development and will ask you to provide that. Close this dialog box.
  15. You can see the created key listed on the page. 

Grant access to the Service Account

Now, as we have created the service account with help of the above steps, you can see the newly created service account under the SERVICE ACCOUNTS section

To grant permissions to the service account, click on the GRANT ACCESS and select "Financial Data"
  • View financial data, orders and cancellation survey questions 
  • Manage orders and subscriptions 
and then click on the button "Invite User"



After sending the invitation, if you are not seeing the new service account added as a user then please enable Google Play Developer Android API. 

Enable Google Play Developer API

Need to enable Google Play Developer API from the Google Cloud Console. Open the Google Cloud Console. 
  1. Click on the HAMBURGER menu (Navigation drawer) and select "APIs and services > Library"
  2. Search for "Google Play Android Developer API" and select the searched result 
  3. Enable this API. 



Comments

Popular posts from this blog

ADB - The Android Developer's Swiss Army Knife

Introduction: In the world of Android app development, having the right tools can make a significant difference. One such indispensable tool is ADB (Android Debug Bridge), a versatile command-line tool that empowers developers and Android enthusiasts to interact with Android devices from their computers. In this blog, we'll explore what ADB is, its key functionalities, how to install it on Windows and Mac, and how it simplifies the app development and testing process. What is ADB? ADB, short for Android Debug Bridge, is a critical component of the Android Software Development Kit (SDK) or the standalone Android Platform Tools package. It serves as a bridge between a computer and Android devices, enabling seamless communication and control over connected devices. How to Install ADB on Windows? Installing ADB on Windows is a straightforward process: Download Android SDK Platform Tools : Go to the official Android Developer website and download the SDK Platform Tools package from this...

A Developer's Guide to verify In-App purchase

  Disclaimer: Helpful document for the coder This document is providing the API calls needed from the mobile device to verify the purchase from the respective stores. The RESTful API will connect with the respective store and verify the purchase, update the user data and will provide the necessary response to the user call. We are going to verify the receipt data from the Apple Store and the purchase token from the Google Play Store. Both stores provide steps to verify/get details of the transaction but this document comes in handy and provides action plans for the mobile app developer and the backend team. Objective Verify In-App purchase/subscription from Google Play Store and Apple Store Requirements Apple IAP Verification: Apple shared secret    Google IAP Verification: Service Account Key file (JSON file)  Key factors: Expertise & Patience  RESTful APIs Purchase subscription/product This will be the first API call from the mobile app to send the purcha...