The Google Play Custom App Publishing API is intended for enterprise mobility management providers (EMMs), third-party app developers, and other organizations who want to enable their enterprise customers to publish private apps (also called custom apps) directly from their end-user interface.
An enterprise customer is an organization that uses managed Google Play to distribute work apps to employees. Each enterprise customer maintains their own managed Google Play store, which can include both public and private apps. Private apps aren't available outside the enterprise—only users with access to the enterprise's managed Google Play store can view and install private apps.
Before you can publish private apps on behalf of an enterprise customer, you need to first enable the Google Play Custom App Publishing API for a project, create a service account, and provide a way for the enterprise to delegate publishing rights to that service account.
Enable the Google Play Custom App Publishing API
To enable the Google Play Custom App Publishing API for a project, follow these steps:
Open the Google API Console. If you don't have a Google account, select More options > Create account and then fill in the form to create an account. If you have a Google account, sign in if prompted.
From the projects list, select a project or create a project.
Search the API Library for the Google Play Custom App Publishing API. To enable the API, select it and then click enable.
Create a service account
As a part of the setup process, an enterprise needs to delegate private app publishing rights to a service account that you control. This service account must belong to a Cloud project and shouldn’t be programmatically created. The steps below describe the easiest way to create a service account:
Open the Google API Console. Login if prompted.
From the projects list, choose the project that you selected or created when enabling the API.
From the main menu, select IAM & Admin > Service accounts > Create service account.
Enter a name for your service account and select Furnish a new private key. Then click Create.
Take note of the service account's email address and store the service account's private key file in a location accessible to your application. Your application needs them to make authorized calls to the Google Play Custom App Publishing API.
Obtain private app publishing rights
As an EMM or third-party app developer, you need to embed a button (or similar feature) into your existing console that sends end users to the Play Console URL below, which guides them through the account delegation process.
service_account: Your service account email address.
continueUrl: The URL to navigate back to after the user completes the account delegation process. If your URL contains characters outside the ASCII set, use URL encoding. We also strongly recommend that you add a security token to your URL.
The link opens the Play Console, where the user is prompted to create or select an appropriate developer account.
If the user doesn't have a developer account:
The user is shown the sign-in screen, where they have an option to create a developer account. After completing the account creation process, including paying a $25 registration fee, the user is given the option to allow your service account to publish apps privately for their organization.
If the user has a developer account, but isn't signed in to the Play Console:
The user is shown the sign-in screen. After signing in successfully, they are prompted to select the appropriate developer account (if multiple accounts exist). The user is then given the option to allow your selected service account to publish apps privately for their organization.
If the user has a developer account and is signed in to the Play Console:
The user is prompted to select the appropriate developer account (if multiple accounts exist). The user is then given the option to allow your selected service account to publish apps privately for their organization.
Retrieve the developer account ID
After the delegation process is complete, the Play Console redirects the user to your designated callback URL (http://foo.com/bar in the example below). A link to the user's developer account and their public developer account ID are passed as arguments.
You need to pass the developer account ID as a parameter when you publish private apps for the user's enterprise.