Tech Hub

Google Play开发者API:如何创建服务帐户

May 4, 2022

Posted by: Rahul Upadhyay

Google Play开发者API:如何创建服务帐户

Why am I reading this?

  • 除此之外,移动应用程序还被许多模块所包围, 应用内购买和订阅发挥了很大的作用, where you as an owner of the app, 能否通过出售消耗性和非消耗性商品(如游戏币)获得收益, Subscription plans for your app many things.  
  • Now, as you are selling some goods on your app, 必须有一种方法来验证购买或获取详细信息. 但很明显,电竞赛事竞猜APP从应用本身来做谷歌提供了SDK. (SDK – Software Development Kit). 但是,我们生活在Android和iOS并存的世界中,这是一个竞争非常激烈的市场!  
  • Google Play Developer API让我们能够从RESTful API中检查用户的交易,从而引导你阅读这篇博客.  
  • With the RESTful API, 我们可以从后端做这个调用,让应用程序独立,做其他事情 

Offering

Google Play Developer API允许你管理项目中的2个主要组件 

  1. 发布API允许您上传和发布应用程序,并执行其他与发布相关的任务.
  2. The Subscription and IN-APP Purchase API lets you manage in-app purchases and subscriptions. [We are going to explore these APIs]

Objective 

验证Google应用内购买和订阅(IAP) 

Requirements 
  1. Google Play Developer Console Access
  2. Google Cloud Console Access
Note: To start making API calls, 你将直接从Google Play控制台设置和管理Google Play Developer API. API可以由Google Play开发者账户所有者管理.  

提示:如果你已经有一个基于Google Cloud Console的现有项目,那么它应该使用与Google Play Console相同的Google帐户. 如果你有一个不同的帐户设置,那么有具体的步骤和角色,我们可以实现这一点. 

 Here are the main steps we are focusing on:  

  1. Set up a new or existing Google Clod Project
  2. 用户,访问Google Play开发者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, 你必须链接你的Google Play开发者帐户到谷歌云项目. In most cases, 我们建议您创建一个新的谷歌云项目专用于您的Google Play开发者帐户, but you can link an existing project. 请记住,每个Google Play开发者帐户只能链接到一个单独的Google Cloud项目. 如果你在同一个Google Play Developer Account中拥有多个应用, they all must share the same Google Cloud Project. 

Access Google Play Developer Console
  1. Log In to Google Play Developer Console Play Console (google.com)
  2. Select your account  
  3. On the side navigation menu, select Setup>AP Access 
     
  4. 同意API服务条款(只要按照屏幕上的说明即可).   
  5. 完成后,您将看到链接现有项目或创建新项目的选项.
  6. 如果你已经有一个谷歌云项目,那么电竞赛事竞猜APP链接这个项目,或者电竞赛事竞猜APP创建一个新项目.
    1. Link existing project
      1. 如果您的项目未列出,请单击Choose project下拉菜单选择现有项目, 验证您的Google Play控制台帐户与角色OWNER和Google Play开发人员API为项目启用. If not then you can do it quickly by following, how to do it? 
        1. Select the project and click on the SAVE button  
        2. You will be seeing a page like this. We need to work on the Service Accounts section. 如果您已经有一个服务帐户,那么您将看到它列出. If not then we will create a new service account.  
    2. Create New Project
      1. 选择Create New Project选项并单击SAVE按钮 
        1. 将创建一个新项目,您可以在下面看到该项目
        2. 我们可以稍后从Google Developer Console编辑项目名称. 

Configure Service Accounts

将访问API的最常见的安全软件服务.  

服务帐户必须在安全的环境中使用,例如您的服务器. 需要安全地管理服务帐户凭据,以便不会向未授权使用API的任何人透露它们. 

一旦我们有项目链接或创建,我们的主要目标是 Create new Service Account or give an access to already created service account.  

  1. Create a new service account
    1. 点击“创建新服务帐户”按钮后,请阅读说明。
    2. 点击选项#1,转到谷歌云平台,在新选项卡中打开该URL 
    3. Now, you are on the Google Console
    4. 单击CREATE SERVICE ACCOUNT并执行下一步
       
    5. Name your service account and provide the description. No need to alter the 2nd field
    6. Click on CREATE AND CONTINUE. Here we need to defile ROLE to this SERVICE ACCOUNT
    7. 搜索Service Account Admin并单击该角色
    8. Once selected, click on CONTINUE
    9. 我们在第三步没有做任何事情,只需点击完成
    10. 您的服务帐户已创建并在同一页面上列出
    11. Select the account and switch to the "KEYS" tab. 我们将为这个服务帐户添加一个新密钥.   
    12. Click on ADD KEY and select CREATE NEW KEY  
    13. Select the Key type as JSON and click on the CREATE
    14. 将创建密钥并要求您下载它. Save the file as it is. 我们将需要这个电竞赛事竞猜APP,并要求您提供. Close this dialogue box.
    15. You can see the created key listed on the page
  2. Grant access to the Service Account
    1. Now, go back to the PLAY CONSOLE PAGE, #7.a from this document. And click on DONE. 您将在service ACCOUNTS部分下看到新创建的服务帐户
    2. 单击GRANT ACCESS(从步骤8开始),您将看到以下屏幕
    3. Check these 2 boxes, click on the INVITE USER
       
      select SEND INVITATION on the confirmation box 
    4. 完成后,您将看到这个屏幕,其中添加了作为User的新服务帐户. If not then please Enable Google Play Developer API

Enable Google Play Developer API

需要从Google Cloud Console启用Google Play Developer API. 打开在步骤中已经打开的Google Cloud Console Create a new service account #c

  1. Click on the Hamburger menu, select APIs & Services > Library
  2. 搜索“Google Play Android Developer API”并点击搜索结果
     
  3. Enable this API. Once enabled
  4. 完成后,您将能够看到步骤中列出的服务帐户 Grant access to the Service Account #d

希望你在阅读这篇博客和去喝杯咖啡的路上玩得开心. Happy setting up. 请在下面的评论区告诉我你的想法和问题. 

Thank you. 

References:

Share this


Back