# Google Service Account Key

To enable server-side purchase verification, the [Google Service Account Key](https://cloud.google.com/iam/docs/keys-create-delete) is essential. Without it, Appflow\.ai cannot validate and process transactions. To obtain and upload the service account key to Appflow\.ai, follow the guide below.&#x20;

*Procedures:*

[*1. Create a new Appflow.ai project in the Google Cloud Console*](#1.-create-a-new-appflow.ai-project-in-the-google-cloud-console)

[*2. Create a Service Account in the Google Cloud Console*](#2.-create-a-service-account-in-the-google-cloud-console)

[*3. Enable APIs in the Google Cloud Console*](#3.-enable-apis-in-the-google-cloud-console)

[*4. Adding the Service Account as a user in the Google Play Console*](#4.-adding-the-service-account-as-a-user-in-the-google-play-console)

[*5. Upload Google Service Account Keys to Appflow.ai Dashboard*](#5.-upload-google-service-account-keys-to-appflow.ai-dashboard)

### 1. Create a new Appflow\.ai project in the Google Cloud Console

1.1  [Head to the Google Play Console](https://play.google.com/apps/publish/) and log in.&#x20;

1.2 First, click on "**Setup**" located on the left-hand side and then select "**API Access**". Once you have clicked on "**API Access**", you will be directed to the following page. From there, simply click on "**Learn more about Publishing API setup**" to navigate to a new page.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FIAtDgkd6VcPrXAxly5BM%2Fgoogle-play-console-api-access.jpg?alt=media&#x26;token=ce772746-b476-45b7-8a5d-098829aeb04a" alt="This is the instruction screen that directs users to Google Play Console>Setup>API access"><figcaption><p>google-play-console-setup-api-access</p></figcaption></figure>

1.3 On the new pag&#x65;*(Google Play Developer API Guides)*, simply click on "**Google Cloud** **Console**" to initiate the creation of a new Google Cloud project. *(Please note that if you already have a Google Cloud Project that you wish to use, you can skip this step.)*

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FD4X2fxLDmOQqTL2xXjqg%2Fgoogle-play-developer-api.jpg?alt=media&#x26;token=f7592e31-28f7-47ca-878e-0ce945e8c061" alt="This is the screenshot of the Google Play Developer API interface"><figcaption><p>google-play-developer-api</p></figcaption></figure>

1.4 On the New Project screen, enter the Project Name. For example, you may use "**my-app-name-appflowai-access**". Let the location remain as it is and proceed to click "**Create**". Then a new project is created.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FEYUsoBdpxjMkhVXkV4HQ%2Fgoogle-cloud-create-new-project.jpg?alt=media&#x26;token=87cf6a3b-5c7e-4fbf-8d15-1890103c28a4" alt="Screenshot for creating a new Google Cloud project"><figcaption><p>google-console-create-new-project</p></figcaption></figure>

### 2. Create a Service Account in the Google Cloud Console

2.1 After the new project has been successfully created, you will be redirected to the page below. Please select "**Create Service Account**".

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FrCDbAPo4PUSvCuIlSpXJ%2Fgoogle-cloud-create-new-service-account.jpg?alt=media&#x26;token=0e8934ed-d7da-48cd-9e65-e3965b7176d2" alt="Instruction screenshot for creating a new service account"><figcaption><p>google-cloud-create-service-account</p></figcaption></figure>

2.2 In the popup window, fill out the following information:

* Service Account Name
* Service Account ID
* Service Account Description

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FtHO6j1sc02K3n1QgqEQK%2Fgoogle-cloud-create-service-account.jpg?alt=media&#x26;token=bfa1b9d8-347d-48a3-a879-73ce383e0c13" alt="Instruction screenshot for filling out store account information"><figcaption><p>google-cloud-service-account-setting</p></figcaption></figure>

Make sure to **copy the email address** located below the Service Account ID for later use. Once you have filled out the necessary information, click on "**CREATE AND CONTINUE**" to proceed.

You will be directed to the "**Grant this service account access to project**" section:

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2F3FSkQg0ws6LdsAs027Dd%2Fgoogle-cloud-service-account-select-roles.jpg?alt=media&#x26;token=bffc1295-a522-45d6-9462-65f44d6ef833" alt="Instruction for granting the proper access for Google service account"><figcaption><p>google-cloud-service-account-select-role</p></figcaption></figure>

Click on "**Select a role**" and choose "**Project>Owner**".

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FxAQhURIEsqi3SlmO4sGw%2Fservice-account-roles-project-owner.jpg?alt=media&#x26;token=ead13d53-a931-4426-8de0-0826a4eef7ba" alt="Instruction for grant owner access for Google service account key"><figcaption><p>google-cloud-grant-service-account-access</p></figcaption></figure>

After selecting the appropriate role, click on "**Continue**".

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2F0L3CqWtEdhf6ds8JdPp1%2Fservice-account-click-continue.jpg?alt=media&#x26;token=3d6d0d52-3a27-4fcc-a08d-61f0bd0c0c06" alt="Instruction for finalizing the creation of the Google service account key"><figcaption><p>goole-cloud-service-accout-finalize-the setting</p></figcaption></figure>

Next, you will reach the "**Grant users access to this service account**" section. Leave this section blank *(no need to enter any information)* and click on the "**DONE**" button below to finalize the process.&#x20;

2.3 Upon completion, you will be presented with the page below, displaying the newly created service account. Click on **the account (hyperlinked)** to proceed.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FNFOxsCeUxQyuQNUreaQZ%2Fservice-account-created.jpg?alt=media&#x26;token=dcd01ead-ef6f-42f7-9652-0dd4c7c21c20" alt="Screenshot that shows a new service account is created"><figcaption><p>newly-created-service-account</p></figcaption></figure>

2.4 Go to the "**KEYS**" panel and click on "**Add Key**". Then, select the option "**Create New Key**".

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2Fe7yQOVFcbtji8DTVyRb9%2Fservice-account-create-new-key.jpg?alt=media&#x26;token=4b09bef4-f587-4064-95f7-70af9bc73bc4" alt="Instruction on how to reach the Google key downloading page"><figcaption><p>google-cloud-create-new-key</p></figcaption></figure>

2.5 Within the pop-up window, select "**JSON**" and proceed by clicking on "**CREATE**". This action will initiate the downloading of the JSON file to your computer. This downloaded file is the one to be [uploaded to Appflow.ai](#5.-upload-google-service-account-keys-to-appflow.ai-dashboard).

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FI9wz37bvVV5gX9fiFxpV%2Fservice-account-create-jason.jpg?alt=media&#x26;token=08916fb8-bf13-40b1-90fd-139368dab43b" alt="Instruction on creating a service account Json key"><figcaption><p>google-cloud-create-json</p></figcaption></figure>

### 3. Enable APIs in the Google Cloud Console

3.1 Go to the [Google Play Android Developer API](https://console.cloud.google.com/apis/library/androidpublisher.googleapis.com) page and click "**Enable**".

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2F15JoyWkYbBG3HLMnFF7L%2Fenable-google-play-android-developer-api.jpg?alt=media&#x26;token=543bbae4-29c7-411d-b76a-5c616bdefe44" alt="This is the page of Google Android developer API"><figcaption><p>enable-google-pay-android-developer-api</p></figcaption></figure>

When the Google Play Android Developer API is successfully enabled, it will appear as follows:

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FOO68SUq8aMV48ZElmsuq%2Fandroid-developer-api-enabled.jpg?alt=media&#x26;token=9ee3f22f-322c-49ab-a699-505615ecbe19" alt="This is the page of Google Android developer API that shows &#x22;Enabled“"><figcaption><p>google-pay-android-developer-api-enabled</p></figcaption></figure>

3.2 Go to the [Google Play Developer Reporting API ](https://console.cloud.google.com/apis/library/playdeveloperreporting.googleapis.com)page and click “**Enable**”.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2F2CCop0PlwiZehXYSraOF%2Fenable-google-play-developer-reporter-api.jpg?alt=media&#x26;token=2186b638-af1f-46c8-8869-926e1bbbd414" alt="This is the page of Google Play Developer Reporting API"><figcaption><p>enable-google-play-developer-reporting-api</p></figcaption></figure>

When the Google Play Developer Reporting API is successfully enabled, it will appear as follows:

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FcDIrjv4OHpCPyoHWCGX2%2Fgoogle-play-developer-reporting-api-enabled.jpg?alt=media&#x26;token=b24cfd0f-3bdd-479f-9752-2d8b380dac36" alt="This is the page of Google Play Developer Reporting API that shows &#x22;Enabled“"><figcaption><p>google-play-developer-reporting-api-enabled</p></figcaption></figure>

3.3 Go to the [Cloud Pub/Sub API page](https://console.cloud.google.com/apis/library/pubsub.googleapis.com) and click “**Enable**”.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2F7A5GqQ6fucZSmlK73Nvu%2Fenable-cloud-pub-sub-api.jpg?alt=media&#x26;token=3ae22e22-9ef7-4b7f-8129-24ebc9a3f9e7" alt="This is the page of Google Pub/Sub API"><figcaption><p>enable-cloud-pub-sub-api</p></figcaption></figure>

When the Cloud Pub/Sub API is successfully enabled, it will appear as follows:

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FSLUb1pMtkyTqDTYb0Ebw%2Fcloud-pub-sub-api-enabled.jpg?alt=media&#x26;token=41abb871-d0ed-4992-b592-d1d6a3e2bbaa" alt="This is the page of Google Pub/Sub API that shows &#x22;Enabled“"><figcaption><p>cloud-pub-sub-api-enabled</p></figcaption></figure>

### 4. Adding the Service Account as a user in the Google Play Console

4.1 Go to [Users and permissions](https://play.google.com/console/u/0/developers/users-and-permissions) in the Google Play Console and click on “**Invite new users**”

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2F7Y9Y3EmZRMFN5WpCYNrJ%2Fgoogle-play-console-invite-users.jpg?alt=media&#x26;token=7539fe20-7ad0-4b92-9e8d-a06be0d0ba84" alt="This is the instruction screenshot on how to reach the User and permissions in the Google Play Console"><figcaption><p>google-play-console-users-and-permissions</p></figcaption></figure>

4.2 On the page that opens, paste the copied email addres&#x73;*(the one you just created in* [*step 2*](#2.-create-a-service-account-in-the-google-cloud-console) *of this guide)* into the "**Email address**" Section and leave "**Access expiry**" unchecked.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FcFm4TgsaTkuIZny9Zzpi%2Fgoogle-play-console-invite-users-email-address.jpg?alt=media&#x26;token=2aa38327-ed00-4f01-bb60-25086f125ef4" alt="This is a guide on how to invite google service account as a user in the google search console"><figcaption><p>google-play-console-invite-users</p></figcaption></figure>

4.3 On the App permissions, add the app you want the user to have access to.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FIq5IpwWURYgyBSo7mgYj%2Fgoogle-play-console-app-permissions.jpg?alt=media&#x26;token=d5eb38d8-c7d2-45c4-92c3-ea7c725278d1" alt="This is the guide screenshot on how to grant service accounts access to specific apps"><figcaption><p>grant-app-permission</p></figcaption></figure>

4.4 Then choose "**Account permissions**", check "**Admin (all permissions)**" then "**Invite user**".

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FijqvTnPMsCLXCimMeLl7%2Fgoogle-play-console-account-permission.jpg?alt=media&#x26;token=3066484f-1bd9-47cc-ad24-7ba58062c879" alt="This is a guide on how to grant account permission for service account"><figcaption><p>grant-account-permission</p></figcaption></figure>

3.5 Click "**Send invite**" on the confirmation pop-up.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FsOjLP9GS8c8MRx4P9eNP%2Fgoogle-play-console-send-invite.jpg?alt=media&#x26;token=e370aee2-563c-4216-927d-1ec7125d58f3" alt="The screenshot of sending invites to the service accounts"><figcaption><p>google-play-console-send-invite</p></figcaption></figure>

Then in the "**Users and permissions**" section, the service account email address should be there with an active status and "**Never expires**" underneath.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FnkkrAUj0B5RZ3e0C8x6S%2Fgoogle-play-console-never-expired.jpg?alt=media&#x26;token=26d846a5-a754-4b3d-b0ca-8e6b926ac682" alt="The status of the invited service account shows “Never expires“"><figcaption><p>user-account-status-never-expires</p></figcaption></figure>

### 5. Upload Google service account keys to Appflow\.ai Dashboard

5.1 Go to[ **Appflow.ai>Settings**](https://dash.appflow.ai/#/settings?project=6242d1eb31b4fca69faa829d), then on the right panel, find **Applications**, and click on “**Manage**” beneath it. You will then be directed to the app listing page.&#x20;

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FonU91a3p0h1nzDW2tFIj%2Fappflow.ai-manage-applications.png?alt=media&#x26;token=648cbb0f-6b19-47b9-bc95-2ddf5895d6c1" alt="The guide on how to reach applications listing page in Appflow.ai"><figcaption><p>appflow.ai-settings-applications</p></figcaption></figure>

5.2 Find the app you wan&#x74;*(you need to add an app if you haven’t done it)*, and click “**Edit**” to access the application editing page.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FNWQkhZR7TpdH4OIaNgHw%2Fappflow.ai-edit-app.png?alt=media&#x26;token=cd6a53ab-8a07-4f52-90dd-6d5d9a369a04" alt="This is the instruction screenshot on how to edit an app in Appflow.ai"><figcaption><p>appflow.ai-edit-app</p></figcaption></figure>

5.3 On the application editing page, Find the “**Google Play Keys**“ section. Click "**Upload service** **account key file**", and upload the keys that you downloaded earlier.

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FjIqrBip7GLMKJvzL4aE8%2Fappflow.ai-upload-service-account-keys.png?alt=media&#x26;token=e4c4fde0-0bf8-440e-be7c-9e938353141b" alt="The guide on how to upload Google service account key file to Appflow.ai"><figcaption><p>appflow.ai-upload-service-accout-key-file</p></figcaption></figure>

If you have completed the process correctly, the **RTDN topic** should be generated automatically below. **Copy it**, and set up the [Real-time Developer Notifications](https://doc.appflow.ai/docs/sdk-set-up-instructions/android-sdk/google-play-store-credentials/google-real-time-developer-notifications-rtdn).

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2Fd0H2unNii07k4f0sDbbP%2Fappflow.ai-rtdn-topic-name.png?alt=media&#x26;token=c5d8b37e-3df8-4c0f-9c56-3399528863d1" alt="The RTDN topic is generated automatically after uploading the Google play key"><figcaption><p>appflow.ai-rtdn-topic-name</p></figcaption></figure>
