104

I am getting the following error while accessing Google Play Developer API using a service account:

The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.

The service account email and .p12 file were generated using the service account option in APIs&Auth -> Credentials. The Application in the Google Play Developer API was linked to the project using the project id as mentioned in google's docs.

However, I am still getting this error when I try to use the Publishing API. I am looking for a solution to this error and a step by step process to use the Google Publishing API for the Java client to publish an APK using the Google Play Developer API. I am using androidpublisher_v2_public.

Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
Koushik Goswami
  • 1,041
  • 2
  • 8
  • 4

8 Answers8

147

I understand you. Google confuses you with changing service names and workflows. Their documents aren't updated enough to match their newest API workflows.

I was using the Google Play Developer Service API v2 on the server-side with an alpha-version APK, and had the same error as you: "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."

This is my solution:

Google Developer Console

  1. "Google Developer Console" > "APIs & Auth" subcategory "APIs" > (api list) "Google Play Android Developer API". Set "STATUS" to "ON".

  2. "APIs & auth" subcategory "Credentials" > "Create new Client ID". Choose "Service account" and create the id.

  3. You should get a P12 key from the browser.

Google Play Developer Console

  1. "Google Play Developer Console" > "Settings" > subcategory "API access".

  2. Make a link to your "Linked Project".

  3. "Service Account" place may be already showing your "Service account" CLIENT ID which made "google developer console".

By default this account is gray indicating that it is not active. So you must activate it and set authority manually.

You should now get a correct response from the API.

If you get the same error again, maybe is because you have configured and purchased products in your console before linking the project.

To solve it, simply add new product in your app.

starball
  • 20,030
  • 7
  • 43
  • 238
kj13
  • 1,765
  • 1
  • 11
  • 14
  • 1
    Yes this worked, thank you! I posted a php sample here: http://stackoverflow.com/a/25825907/1745234 – Fabrizio Farenga Sep 13 '14 at 17:50
  • Remember that, you can not create more than one "Linked Project" in Google Play Developer Console. So, you can use the same .p12 file in all of your projects. – woheras Jun 22 '17 at 09:23
  • Can I call play developer API from Android APP? – Manukumar Apr 27 '18 at 06:08
  • I am having a strange situation... SOMETIMES I get this error, and SOMETIMES my purchase is verified. It seems inconsistent and I cannot detect a pattern. Any thoughts? – Jeff Padgett Sep 07 '18 at 17:50
  • Could it be because I am testing on internal track? Google docs say: – Jeff Padgett Sep 07 '18 at 19:30
  • Google Play accumulates completed test purchases for each user but does not pass them on to financial processing. Test purchases are not automatically canceled, so you might want to manually cancel a test purchase to continue testing. To do so, open the app page in the Play Store. If the test purchase that you want to cancel is a subscription, you can also use the cancel() method of the Purchases.subscriptions API. See here: https://developer.android.com/google/play/billing/billing_testing#testing-subscriptions – Jeff Padgett Sep 07 '18 at 19:30
  • 2
    In step 2 of Google Play Console, what should we select in [Select a Role] dropdown menu? – Nj Subedi Nov 16 '18 at 06:06
  • Below are the steps should be followed on Gcloud, 1.create a project on Gcloud, 2.on the right side panel tap on API & Services -> Create a Service Account, 3. on the right side panel tap on Pub/Sub -> i).Create Topics, ii).Create a Subsction, iii). now set the permission to google-play-developer-notifications@system.gserviceaccount.com as described here https://developer.android.com/google/play/billing/realtime_developer_notifications#grant_publish_rights_on_your_topic, it works – User2364902 Nov 24 '18 at 07:48
  • Also make sure that you create the product AFTER you linked (cf AFT's answer) – Paulin Trognon Jun 25 '19 at 04:37
  • 2
    This guide was a bit old. Here a more up-to-date version: Google Cloud Platform: https://console.cloud.google.com/home/dashboard Hambuger menu → Apis & Services → Credentials Manage Service accounts Create Service Account Name it and press Create Role: Token Creator Continue Create Key P12 / JSON Done – Jarzka May 12 '20 at 09:12
46

Got the same error trying to validate in-app purchases.

This has worked for me:

Go to

Google Play Developer Console > Settings > API Access.

Find your project under "Linked Project" and click "Link" button.

If you get the same error again, maybe is because you have configured and purchased products in your console before linking the project.

To solve it, simply add new product in your app.

Andrea Scalabrini
  • 1,442
  • 2
  • 18
  • 25
  • 6
    Creating all products new finally solved the issue for me, thanks! – David Schumann Dec 12 '18 at 15:06
  • 5
    Same here, but I just created a new temporal product, then I just deleted it :) – mayo Jan 08 '19 at 17:49
  • 1
    Is this a viable solution if there are users who purchased the products? – Ozgur Akcali Mar 20 '19 at 14:35
  • 9
    I was able to fix by setting each product as "INACTIVE", then save, then make "ACTIVE" again. – JeremyTM Apr 03 '19 at 04:50
  • 4
    Works also by setting just a single product to inactive and then back to active state – alex.dorokhov Jun 12 '19 at 16:56
  • That's great! It's worked for me. Thank you so much – SadikAli Jul 26 '19 at 07:08
  • I had the same issue when trying to validate GP subscriptions (which cannot be made INACTIVE once they have been set to ACTIVE). I fixed the "project ID is not linked" problem by changing the name of the subscription listing and saving, and then quickly changing it back again. After that the API call worked immediately. – TheBestBigAl Jun 03 '20 at 15:55
  • To add a new product: Play Developer Console > All Apps > Select your app > Store presence > In-app products > Managed products – React Dev Aug 28 '20 at 11:22
  • so we can not access the older purchases through this API if the project was not linked as yet? – dgarg Nov 12 '20 at 07:21
  • 2022 can't access void purchase list :( I link project later but products were added before in Google Play Console, even I Deactive and then Active all products but void purchase list not coming in v3 google api – Muhammad Shahzad Sep 26 '22 at 07:28
30

If you receive this response when making a request to Android Publisher API, but your project is already linked try to create new In-App Product. If there is a product created before linking, it fails on product transaction fetching when making a purchase. With new product, error goes away.

https://dev.to/sandris/androidpublisher--projectnotlinked-error-43c7

AFT
  • 45
  • 7
  • 22
4

Should anybody have an issue on trying to find where to link the project (as the interface keeps changing) here's is a current link to their API docs

Google Play Developer API

And if you want a direct link (should their docs change as per usual) then you can find the link page at:

play.google.com/apps/publish/?account=<your_account_id>#ApiAccessPlace

Just for reference, I'm trying to reconcile subscriptions on the server side and after all the oAuth 2.0 has been setup, I'm getting a 403 error :

  "error": {
    "code": 403,
    "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
    "errors": [
      {
        "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
        "domain": "androidpublisher",
        "reason": "projectNotLinked"
      }
    ]
  }
}
Nicholas Mordecai
  • 859
  • 2
  • 12
  • 33
  • 2
    If you're signed into multiple Google accounts, it will be hard to access this page using the correct one due to all the redirects. You're best off using incognito mode to sign into the correct Google account. – Benjamin Carlsson Aug 15 '20 at 16:19
  • 1
    @BenjaminCarlsson add &authuser=2 to the end of the URL. – Luc Bloom Apr 14 '23 at 15:14
  • 1
    Sometimes it also helps to insert /u/2/ after the domain part of the URL. – Luc Bloom Apr 14 '23 at 15:14
3

A couple of days ago I faced the same problem described here with an Android publisher v3 and I did it all by instruction but unfortunately unsuccessfully.

It may happen when you did link your google cloud console after your subscriptions/products were created and here I'm going to describe the tricky solution on how to solve this problem without even contacting Google.

I thought that it might be a problem of synchronization and did a couple of steps.

Solution:

  1. Link your Google Cloud Console account to your Google Play Console if it isn't done yet.
  2. Then go to your subscriptions/products and try to change something there, for example, the description, and roll it back.
  3. Then do it with all the rest subscriptions/products

Finally, recheck your integration. I hope everything should get working now :)

Also, I hope #google will fix these issues soon.

suquant
  • 2,085
  • 1
  • 12
  • 11
  • Can we change subscription price and roll it back again immediately ? i can not able to access Google Play Developer API Subscription get Access call ? I already have subscription created before and then link up project to google play console in API access could this be the cause ? should i change subscription price and roll it back ? will that work ? – Jay Rathod Dec 09 '20 at 13:46
  • @JayRathodRJ Yes, it should help, actually, that is what I am talking about here. – suquant Dec 13 '20 at 15:18
3

Your problem may have caused because you created in-app purchase products before creating the service account.

In your developer console, set your in-app purchases product as "INACTIVE". Then save the page. Finally make then "ACTIVE" again. This will refresh things in Google's end, and make everything work.

coolcool1994
  • 3,704
  • 4
  • 39
  • 43
1

Check your fastlane/Appfile.

Your package_name match with your project package and the project created in your google account.

augustocbx
  • 762
  • 8
  • 8
0

In case of codemagic

So in my case the problem was because of the Service account key, the json key was created before the access/permission was granted to that service account, so after deleting the old key and creating a new one works for me.

xkxeeshankhan
  • 351
  • 4
  • 8