ChatGPT解决这个技术问题 Extra ChatGPT

Google Play Developer API - "The current user has insufficient permissions to perform the requested operation."

I have a Google dev console process with Google Play Developer API is enabled and the project is linked to Google Play project. In Google Dev console project, created OAuth Client ID (web application) (I'm an owner of the project). Using "client_id" and "client_secret" to authenticate. Tried to using google-api-client in Python, Google Developer API Playground to send request to list reviews of our apps but got error: "The current user has insufficient permissions to perform the requested operation." Details as below: Request:

GET /androidpublisher/v2/applications/<package_name>/reviews

Response:

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

Did I miss anything?


D
Dharman

There is a very important thing about receipt validation using Google Play Android Developer API.

If you added your in-app product BEFORE granting permission or linking to your service account, you need to open "In-app products" and perform some update. You can for example edit description of your product and save. You should instantly get permission.


This is the key. Damn you, Google. Any Google developer API experience has been trash but this takes the cake.
This works for me. For addition, make some changes in Grow -> Store presence -> Main store listing or Monetize -> products -> In-app products/Subscriptions also take effect.
Editing the description didn't work for me, creating and activating a new product did though (even for validating receipts for the old product).
This solution still valid to July-2022, lol :))
b
bikram

I looked everywhere on the internet and found somewhere that you might need to wait for at least 24 hours.

Ensure you have done everything correctly as below.

Go to https://console.cloud.google.com Create a project (or select existing project) Create a service account with role Pub/Sub Admin Go to https://console.cloud.google.com/apis/library and search for "Google Play Android Developer API" Enable that API Go to https://play.google.com/apps/publish Go to Settings > Developer account > API Access Link the project that you created in step 2 The service account will appear that you created in step 3 Grant access to it with Finance permission to the app in play console Very important: Wait for at least 24 hours for changes to take effect.


"Create a service account with role Pub/Sub Admi" I don't see how to add that role? Is this still valid? I already created the service account and I am getting the error mentioned here.
@salyela When you create a service account, after clicking next you will need to choose the role to service account (this is optional but need to add to make it work). See this ibb.co/5RysC1B
@Bikram Hi, Is 'Finance Permission' enough for get subscription data? (or) Need to give full permission?
@DhineshYes That would be enough I guess.
This is gold! Thank you, worked like a charm. Otherwise I guess we would have to wait for 24hs
i
ihsanberahim

If you followed all what @Bikram listed and you still facing the same error. Do this, create 'Managed product' temporary and then delete them. This way, sure you don't have to wait 24 hours.

It works for me.


This just literally saved me! I wish I could award this answer a bounty!
OMG. I did not believe this would work, but it did. Thank you so much!
Thank you! This works now on December 18, 2020.
That made the trick for me as well, thanks! :)
I have tried all the above answers, now I'm trying your answer can you please help me with that. I have subscription plans so I'm adding new subscription plan from Monetize>Products>Subscriptions .but I'm not able to delete the subscription plans. Am i doing something wrong? My account has admin access but I'm not an owner.
g
gridsquare

After adding a new user in the Google Play Console, Google needs up to 24 hours to propagate all access rights for all apis.

I ran into the same issue, when I've tried to using the oauth2 flow to access the Inapp purchases status api. It's not official documented, but this github comment helped me to figure this out.


I'd been suffered hard for a whole day before I found this answer. THANKS a lot! This answer should be accepted as a right one!
A
Ankit Jindal

I faced a similar issue, the problem is in the settings we do in google developer project.

Refer to create-play-service-credentials for settings. Use the same primary account with which you created your in-app products.

Make sure you remove the previous one.

Link to a Google Developer Project Your Play Developer account needs to be linked to a Google Developer Project.

1a. Open the Settings > Developer account menus and select API access

https://i.stack.imgur.com/0tPP1.png

1b. Select Link to connect your Play account to a Google Developer Project

https://i.stack.imgur.com/o26Kp.png

1c. Agree to the terms and conditions

https://i.stack.imgur.com/Xa14G.png

2. Create Service Account Next we need to create a service account. This is done from the Google API Console.

2a. Select Create Service Account

https://i.stack.imgur.com/ASOsS.png

2b. Create Service account key credentials

https://i.stack.imgur.com/UGbtF.png

2c. Enter details for service account

https://i.stack.imgur.com/H5Ftu.png

https://i.stack.imgur.com/XIXCN.png

3. Grant Access

3a. In Play Console, select Grant Access on the newly created service account

https://i.stack.imgur.com/e9cnS.png

3b. Grant the following permissions:

https://i.stack.imgur.com/mlUDa.png

After granting access, Google takes 24-48 hours to propagate all access rights for all API's, till that time you'll continue to get the same error.


Do we first need to select add app to grant permission or not ? Here in 3b steps it is asking to Me to invite user on my service account email ? do we need to do that or we need to enter any valid gmail account email because when i go to grant access it shows me invite user ? Any help will be appreciated as stuck on this..
For granting permissions to user you need to add the email and then set role as Editor, Admin etc. For grant permissions to app, you need to add that app first.
But while i am granting permission it is taking email as service account id as last screen shot 3a in your answer so we should give it permission to that right ?
Thanks for taking the effort to add screenshots. Google's systems are so ass backward and broken it is hard to know exactly which screen(s) you should be on otherwise.
Yea, I have to spend like few days just to figure out this mess. We generally some generic errors with which sometimes it is difficult to find what could be wrong.
E
Enakhi

Wait up to 24h OR create/edit any In-App product to force permission update,it takes 1-2 minutes to update and no need to wait 24h.


S
Shivam Yadav

For someone who is facing this exact issue then the simple answer is to check the permissions to the service account which is linked in the Google Developer Console.

1.Open the Settings > Developer account menus and select API access 2.Choose the service account and check the permissions- REMEMBER FINANCE PERMISSION IS MUST FOR THIS ACTION

https://i.stack.imgur.com/Xljcw.png

And after giving the permission update your subscription/package and make a new purchase then try again.

Happy Coding!


p
panser

I used service key and created it in Google APIs Credentials Cloud Platform, and I had the same issue until I added my created service key to Google Developer Console with all access.

I understood that you already created credentials in Google Developer Console, but maybe my experience will help someone else


I finally found that my email using for authentication need to be also granted permission on the Google play store project to use the API(s).
J
JT501

For my scenario:

If you are using service account to verify purchase via Google Play Developer API. Ensure you also click the View app information and download bulk reports (read only) permission besides the Financial data permissions.

https://i.stack.imgur.com/ajXRh.png

After edited the permissions, update the in-app products and subscription (eg. change the descriptions).

Then wait for around 30 mins, the permission error gone. 🎉


D
Dharman

For me the reason i had this issue because I did not check the permission to Release to production, exclude devices and use app signing by Google Play in Google Playstore console for the service account I created to manage app creation and management.

So check Users and Permission in the Google Play store console and check if the appropriate permission is checked.


S
Shoaib Ahmed

It will automatically be fixed after 24 hrs, don't waster your time and energy with hacks, just wait and watch.