22

I'm having trouble with androidpublisher.inapppurchases.get

My project is just according to https://code.google.com/p/google-api-java-client/wiki/OAuth2#Service_Accounts and it worked fine until I migrated to new Google Play Account. So now when I execute request Server-to-Server I am receiving this response.

{
  "code" : 401,
  "errors" : [ {
    "domain" : "androidpublisher",
    "message" : "The current user has insufficient permissions to perform the requested operation.",
    "reason" : "permissionDenied"
  } ],
  "message" : "The current user has insufficient permissions to perform the requested operation."
}

Anybody is familiar with this response because in google documentation there is no clue about this.

Patrick Q
  • 6,373
  • 2
  • 25
  • 34
stebetko
  • 735
  • 1
  • 8
  • 24
  • Requests without a "person" param also result in the above error. Fix suggested in this related post http://stackoverflow.com/questions/24306678/google-api-ruby-client-the-current-user-has-insufficient-permissions-to-perform#comment38031226_24306678 – ZX12R Nov 17 '16 at 16:52

4 Answers4

33

Problem solved adding user service account email address xxxxx@developer.gserviceaccount.com as administrator user in google play settings.

stebetko
  • 735
  • 1
  • 8
  • 24
  • i am having the same issue, but i didn't understand, where to put it . which settings ? my request is : https://www.googleapis.com/androidpublisher/v1/...?access_token=... – user987760 Jan 26 '15 at 15:02
  • Go to google play console and add service acount email adress from google developer console to settings -> permissions or something like that. I can't tell you exactly the path 'cause I have no longer access as administrator to this app. Hope this help. – stebetko Jan 28 '15 at 11:45
  • Thanks! Great! Worked! – Erick Engelhardt Jan 08 '16 at 02:01
  • Yes fixes, but only for "Purchases.subscriptions: get" . when i calling "Purchases.subscriptions: cancel" getting same permission permissionDenied issue (i already give Administrator permission) ? – Deven Apr 05 '18 at 13:50
  • For me adding the specific app as a new column in the Users and Permissions page in Google Play Console did the trick - afterwards I didn't have to set the service account to Admin, it worked with just a few relevant check boxes checked. – Captain Dashenka Jul 23 '18 at 15:55
  • 3
    Actually not in google play settings , but at play.google.com->settings->API access -> service accounts -> grant permission – Chirag Purohit Sep 04 '18 at 09:40
  • Created a new service account in play console with Administrator permission but still getting same error. Any other suggestions ? – Nency Jul 18 '19 at 09:12
11

From Google Play Console go to (with admin access):

  1. Setting (Left Panel)
  2. Developer Account (Left Panel)
  3. Users & permissions (Left Panel)
  4. Click on the Invite New User button.
  5. Enter the service account email (the same you have in the json file you are using and that google generated when you created the service account)
  6. Select Administrator in the Role DropDown menu.
  7. Click on SEND INVITATION

That's it. No one can stop you now! :)

Valerio
  • 278
  • 1
  • 6
  • 18
4

Unfortunately, the accepted answer did not work for us. For verifying a receipt you would need an Access Token. The Access token is being generated by RefreshToken. RefreshToken has an association to a Google account. That Google account should have View financial information In Google Play console.

  1. Get Redirect Url using Android Client ID
  2. Use Redirect URL with a Financial Access Enabled Account to get Refresh Token
  3. Get Access Token with that Refresh Token
  4. Use Access Token to verify IAP receipts
Roozbeh Zabihollahi
  • 7,207
  • 45
  • 39
2

For those of you that run into this issue and the above solutions don't work and your service account has sufficient permission in Google Cloud and Google Play Console, it can take ~24 hours+ for permissions to propagate (according to other users).

But there's a hack to fix this: update/change/create an in-app purchase in the Google Play Console under the YOUR_APP > Products section.

Fix mentioned on Github

brianbhsu
  • 670
  • 7
  • 12
  • Updating the Main Store Listing (e.g. the app title or description as shown in the Play Store) also seems to make the changes take immediate effect rather than having to wait. – nating Jan 27 '22 at 10:43