7

I have followed these steps:

  1. Go to Google Cloud Console and create/select a project.
  2. On the header, click to open the menu and select ‘Pub/Sub’, or click https://console.cloud.google.com/cloudpubsub/topic/list
  3. Create/select a topic.
  4. Add the service account google-play-developer-notifications@system.gserviceaccount.com, and grant it the role of Pub/Sub Publisher.
  5. Create a subscription. There are 2 types of subscription:
    • Pull: we need to configure our server to pull for new messages.
    • Push: Similar to ios, the notification is send to the endpoint we configure.
  6. Go to Google Play Console and select your app.
  7. Click on ‘Development tools’, then ‘Service & APIs’.
  8. On Real-time developer notifications type the topic name.
  9. You can send a test notification to test that all is connected.

But When I send test notification I get this error:

An error occurred with the test publish on topic projects/project_id/topics/topic_name. Ensure that the topic is correctly created and configured, and the required permissions are set. Refer to the Real-time Developer Notification's Pub/Sub Guide to learn more.

But

  1. I have given pub/sub publisher permission to my service account.
  2. topic name is correct too.
  3. I am able to send test message from this topic in google developer console and I am receiving that response on my server.

any help is appreciated.

Long Luong
  • 764
  • 2
  • 14
  • 28
Navjot
  • 73
  • 1
  • 4
  • When you say you have given pub/sub publisher permission to "my" service account, do you mean the google-play-developer-notifications@system.gserviceaccount.com service account? – Kamal Aboul-Hosn Oct 01 '20 at 11:54
  • Can you share the topic name (obfuscated if needed, just to view the format that you used) – guillaume blaquiere Oct 01 '20 at 12:04
  • @KamalAboul-Hosn yes i have added pub/sub publisher permissions to the service account i created which end with gserviceaccount.com – Navjot Oct 01 '20 at 12:22
  • @guillaumeblaquiere topic name format is this only projects/project_id/topics/topic_name – Navjot Oct 01 '20 at 12:22
  • Thanks, it was to be sure. Can you also share the name format of the granted service account? – guillaume blaquiere Oct 01 '20 at 12:41
  • 1
    You shouldn't be using a service account you created. You need to give permission to the existing service account "google-play-developer-notifications@system.gserviceaccount.com" – Kamal Aboul-Hosn Oct 01 '20 at 13:56
  • @KamalAboul-Hosn can you tell me how can we get user id of user who has purchased a subscription from the body. We receive sku, notificationType, purchaseToken, subscriptionId in subscription object – Navjot Oct 07 '20 at 05:45
  • @Navjot since that is a separate issue, it would be best to enter a new question. – Kamal Aboul-Hosn Oct 07 '20 at 13:10

1 Answers1

20

The step that is typically missed in cases like this is the one to grant the Publisher role to the service account google-play-developer-notifications@system.gserviceaccount.com. This is not a service account that one creates, but one that already exists. This is the service account that the Google Play infrastructure uses to publish, which is why it must be this specific account that is granted the Publisher role.

Kamal Aboul-Hosn
  • 15,111
  • 1
  • 34
  • 46
  • That service account does not exist for me, how do I trigger its creation? PubSub API is enabled on GCP. – OrangePot Feb 24 '21 at 20:30
  • 2
    You don't need to create it and it shouldn't exist "for you," so you won't find it listed in your set of service accounts. This is a Google-owned service account that you need to give permission to. – Kamal Aboul-Hosn Feb 25 '21 at 00:03
  • 2
    That was my source of confusion. The account is not listed in IAM nor does it show up in autofill suggestions when trying to grant topic permission to the account. I had to type the full name `google-play....account.com`, and it was accepted. – OrangePot Feb 25 '21 at 17:15
  • 3
    Is that written anywhere in the docs? I am glad I found this topic. For clarity: 1. Open the Google Cloud Platform 2. Navigation Menu -> Big Data -> Pub/Sub 3. On the right side under 'PERMISSIONS', click on 'ADD MEMBER' button 4. Under New Members look for: - google-play-developer-notifications@system.gserviceaccount.com 5. Under Select a role, - look for 'Publisher', - and select: Pub/Sub Publisher 6. Save (and that's it) Now go back to the Google Play Console, your app -> Monetization setup and test the real-time developer notifications again. – goldensoju Mar 10 '21 at 05:55
  • This service account doesn't exist for me. I can't find it following any of the above directions. – James Parker Apr 23 '21 at 18:16
  • 1
    Ok, got it. Per @OrangePot I had to paste the full name, google-play-developer-notifications@system.gserviceaccount.com, in. If I typed in a portion of it it doesn't find it. COPY & PASTE IT IN. Balls. – James Parker Apr 23 '21 at 18:33