vnoob0
vnoob0

Reputation: 389

AndroidPublisher API return projectNotLinked error

This happens when I was using Google Play Android Developer API in Google Developers Console to test the status of purchased product, and the result is always like this

{
 "error": {
  "errors": [
   {
    "domain": "androidpublisher",
    "reason": "projectNotLinked",
    "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
   }
  ],
  "code": 403,
  "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
 }
}

Have checked this out using another Developer account (and package name) and it works just fine. I sure have linked the API project from Google Developers Console to Google Play Developer Console -> API Access settings, and try to recreate as many as possible but none of the projects worked.

So what am I missing here? What does it mean "not linked" besides the linked project I made in the settings of Google Play console.

Upvotes: 18

Views: 12481

Answers (8)

Viết Ưng
Viết Ưng

Reputation: 11

I have exactly the same issue. but i have resolved . [request]: - you must link project Google Play Developer Console before you create inapp purchase

Upvotes: 1

Lars Peter Larsen
Lars Peter Larsen

Reputation: 321

Make sure the InApp-product is created after linking the API-project.

If you (like me) created the InApp-product first, and then linked the API-project afterwards, you will not be able to call any of the androidpublisher.purchases.* endpoints without getting the "projectNotLinked"-error. Neither from code or via the API-explorer.

You can verify this is the problem by calling androidpublisher.inappproducts.list. If this succeeds, your API-project is correctly linked to the Google Play Console...

It will not help to recreate users in Google API's. Nor to change authentication between OAuth 2.0 client IDs or Service account keys. Everything will work as expected when you create a new InApp-product after linking the API-project.

Upvotes: 10

Diyan_K
Diyan_K

Reputation: 171

In case anybody else has the same issue, try adding a new product/subscription in your Google Play console account. That worked for me, although seems to be some kind of inconsistency problem in Google services.

Upvotes: 13

Trenton
Trenton

Reputation: 11996

The APIs Explorer doesn't appear to work with v2 of the API. A bug has been reported: https://code.google.com/p/google-apis-explorer/issues/detail?id=268

Upvotes: 1

Fabrizio Farenga
Fabrizio Farenga

Reputation: 470

You need to link the project in the Google Play Developer Console under Settings -> Api Access.

See my complete answer here: https://stackoverflow.com/a/25825907/1745234

Upvotes: 2

vnoob0
vnoob0

Reputation: 389

After days trying to use API Explorer to use Android Publisher API but failed, I requested support from Google and receive the answer "It looks like API Explorer is no longer supported for the Publishing API". So basically I can't use API Explorer to check in-app purchase token again. Hope this help who's struggling with this.

Upvotes: 10

Dushyanth
Dushyanth

Reputation: 461

I got the same error message when using a "SERVICE ACCOUNT" for authentication. But everything works fine when using a OAuth client of type "installed application". To fix:

  1. Go to the API Access page on the Google Play Developer Console.
  2. Click on "Create oAuth client" button.
  3. Make sure you select "Installed Application"
  4. Use the generated client id and secret to get access/refresh tokens as described in https://developers.google.com/android-publisher/authorization
  5. Use the access token to make api requests.

Upvotes: 0

Brian White
Brian White

Reputation: 8756

I got this too and just gave up on getting it to work, instead switching back to v1.1 of the API:

final URL url = new URL(
        "https://www.googleapis.com/androidpublisher" +
        "/v1.1/applications/" + "com.example.app.id" +
        "/subscriptions/" + subcriptionId +
        "/purchases/" + googlePurchaseReceipt +
        "?access_token=" + googleAccessToken);

Hopefully someone will post a better answer sometime and we can all switch to v2 of the API.

Upvotes: 2

Related Questions