Tech Hub

Google Play Developer API: How to Create a Service Account

May 4, 2022

Posted by: Rahul Upadhyay

Google Play Developer API: How to Create a Service Account

Why am I reading this?  

Mobile applications are surrounded with 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 an 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 the world where Android and iOS existent and in 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 2 main components in your project 

  1. The Publishing API lets you upload and publish apps, and perform other publishing-related tasks.  
  2. The Subscription and IN-APP Purchase API lets you manage in-app purchase and subscriptions. [We are going to explore this 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 setup 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 different account setup then there are a 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. User 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 navigation menu, select Setup>AP Access 

 

 

4. Agree with API terms of service (Just follow on screen instructions if any).   

5. Once done, you will be seeing options to link your existing project or create a new project.  

 

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

Link existing project  

 

a. 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? 

i. Select the project and click on the SAVE button  

 

ii. You will be seeing a page like this. 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 

b. Select the option Create New Project and click the SAVE button  

 

i. A new project will be created and you can see that project as listed:  

 

ii. We can edit the project name later from the Google Developer Console.  

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 project linked or created, our main Goal is to Create new Service Account or give an access to already created service account.  

7. Create new service account  

a. Read the instruction once you click this button, "CREATE NEW SERVICE ACCOUNT"   

 

 b. Click on the option #1, Go to the Google Clod Platform and open that URL in the new tab 

 c. Now, you are on the Google Console,  

 

 d. Click on the CREATE SERVICE ACCOUNT and follow the next step  

 

 e. Name your service account and provide the description. No need to alter the 2nd field  

 

 f. Click on CREATE AND CONTINUE. Here we need to defile ROLE to this SERVICE ACCOUNT  

 

 g. Search for Service Account Admin and click on the role  

 

h. Once selected, click on CONTINUE  

 

i. We are not doing anything in the 3rd step, just click DONE  

  

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

 

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

 

l. Click on ADD KEY and select CREATE NEW KEY  

m. Select the Key type as JSON and click on the CREATE 

 

 n. The key will be created and will ask you to download. Save the file as it is. We will need this for the development and will ask you to provide that. Close this dialog box. 

o. You can see the created key listed on the page 

Grant access to the Service Account  

8. Now, go back to the PLAY CONSOLE PAGE, #7.a from this document. And click on DONE. You will see the newly created service account under the SERVICE ACCOUNTS section  

 9. Click on the GRANT ACCESS (from step 8) and you will be seeing the following screen 

 

10. Check these 2 boxes, and click on the INVITE USER  

select SEND INVITATION on the confirmation box 

 

 11. Once done, you will be seeing this screen with the new service account added as a User. If not 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 which you already have opened in the step #7.c 

a. Click on the Hamburger menu, select APIs & Services > Library  

 

 b. Search for "Google Play Android Developer API" and click the searched result   

 

c. Enable this API. Once enabled,  

 

d. Once done you will be able to see the Service Account listed in step #11  

References: 

Getting Started | Google Play Developer API |Google Developers  

Quotas | Google Play Developer API | Google Developers

Create a service account - Google Workspace Admin Help  

Creating and managing projects | Resource Manager Documentation | Google Cloud 

Share this


Back