Nguyen Hoang
Nguyen Hoang

Reputation: 1181

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?

Upvotes: 118

Views: 71479

Answers (26)

stackers
stackers

Reputation: 3279

Editing a products name/price/description/status did not work for me, and neither did editing the apps title/description, but my store page was still saved as a draft.

I finished filling out the store page and saved it, and it immediately started working.

Google, you suck and I hate you, you wasted 6 straight hours and half my sanity, thinking I was just too stupid to understand how to configure your stupid service accounts. Turns out I was doing everything right. And instead of fixing these things you're just pouring all your money into AI, which has no purpose other than tricking investors. Google is a garbage company with garbage products.

Upvotes: 0

Samuel Adam
Samuel Adam

Reputation: 1337

Someone who still struggles in 2025 here, no AI tools comes up with this answer, so hooray for Stackoverflow! :)

What worked directly was to create a new placeholder subscription (This really needs to be in your doc, Google, no shame admitting this).

Tried, but didn't work (at least directly):

  • Edit subscription description
  • Toggle a country in subscription
  • Add tag in subscription

Upvotes: 0

Spiros Mitropoylos
Spiros Mitropoylos

Reputation: 151

2024 Answer sum up

Start by creating a Google Cloud account (you need to add a payment method - a card) Having an active Google Cloud account and an already uploaded and activated/certified app in the Google Play Console.

Having already created a product and/or subscription.

  1. In Google Cloud, you need to activate the "Google Play Android Developer API". (It exists under "APIs & Services " of the left menu when writing this)
  2. From the same platform, you need to create a Service Account (under Credentials). The automatic email that will be created - should be registered in Google Play Console - Users and Permissions!
  3. In Google Play Console, on the home screen (not in-app), under the "Users and permissions" menu, using "Invite Users", you need to put the email from step 2. It should directly become "Active" and green. (as permissions of here Admin - you set it after it works - they write that you only need Financial data)
  4. Go to a Product or Subscription and do Activate -> Deactivate -> Activate and/or change an item in the description.

In my environment, once the above was done, I didn't have to wait at least 24 hours for it to work. It worked immediately.

When I changed the permissions from "Users and Permissions" in Google Play Console, it took a few minutes to change.

Upvotes: 15

Binh Ho
Binh Ho

Reputation: 4973

If you confirmed all steps and it not works, let try this step. It worked for me.

    1. Go to Google Play Console
    1. At left panel menu Product -> Subscriptions
    1. Select a product -> Deactivate then Activate again

Actually any update on Subscriptions -> Plans/Offers should be a trick as well.

enter image description here

Upvotes: 1

Banzindun
Banzindun

Reputation: 51

On our project we had Google Play API working correctly. Then we transferred the project to a different account, which broke the permissions.

I tried giving permissions to the old service account, creating a new service account every time doing the trick with in-apps, or waiting 24 hours. Nothing worked.

Today I tried to disable the Android Developer API and enable it again after a while. That has fixed the issue for us.

Upvotes: 3

Tariqali
Tariqali

Reputation: 389

I was getting below response when verifying purchase using service account to call purchase API.

Status: 401, message: The current user has insufficient permissions to perform the requested operation.

The reason was that I not included the service account credentials in Google Play console. Settings -> Developer account -> API Access are now not showing on the Google Play Console.

So below are the steps I perform after that to get response from Purchase API:

1. In the Google Cloud Console go to Service Accounts and create.

Step1

2. Assign the Role.

Step 2

3. Go to the Users & Permissions page on the Google Play Console and Click Invite new users.

Step 3

4. Put an email address for your service account in the email address field.

Step 4

5. Add an app to grant the permissions and then click on manage permissions. Step 5

6. Grant the necessary rights to perform actions and click Invite user.

To use the Google Play Billing APIs, you must grant the following permissions:

ā€¢ View financial data, orders, and cancellation survey responses

ā€¢ Manage orders and subscriptions

Step 6

After these steps create or update the existing product/subscription name, country it will affect instantly without any delay. This is needed because you created product/subscription id before granting permissions.

Reference and more details

Done

Upvotes: 7

Kumar M
Kumar M

Reputation: 161

In 2024: In My case it worked after adding the service account email in "Users and permissions" section of Google Play Console. I have Subscriptions not the products.

Important note: that we need to wait at-least 24hrs after adding the user in Google play console

enter image description here

Upvotes: 2

Nicolas Castro
Nicolas Castro

Reputation: 1552

For those that have been using the credentials without issues until a specific moment, and don't have access to the Play Developer Console, you must know that these keys expire. After re-enabling it, it will take some hours until it starts working again.

Upvotes: 0

Azar-Ro Cohen
Azar-Ro Cohen

Reputation: 51

Just in case someone stumbles upon this question, based on the information in this answer, it appears that Google has significantly altered the way service accounts access the Google Play Console. Notably, the "API Access" menu option seems to have been removed. During the billing setup, you might have noticed the requirement to grant permissions to your tester list, allowing them to make purchases while developing the in-app products feature. If you've followed all the steps correctly (which can be challenging, given the complexity and organization of Google's documentation), the service account email you created and added to the Google Play Console should also be included in your list of testers. You can find the License Testing section here.

Upvotes: 5

Bikash Shah
Bikash Shah

Reputation: 41

Yes, "Settings > Developer account > API Access" has disappeared in Google Play Console now! Instead, follow @BitQuestions instructions on inviting the service account user (email address of the service account) and grant the financial data permissions as per @Shivam Yadav

Also, @ihsanberahim tip was great to avoid 24hr delay in permissions propagation.

Upvotes: 3

HongSec Park
HongSec Park

Reputation: 1221

1.Go to Settings > Developer account > API Access

  1. but the API access one click connect function is deprecated.
  2. so we should add the service account address to <play store console, users-and-permissions>(https://play.google.com/console/u/0/developers/${your project id}/users-and-permissions)
  3. set account permission.

done

Upvotes: 0

Shivam
Shivam

Reputation: 851

Guys if your purchase API is giving error with The current user has insufficient permissions to perform the requested operation.

All you need to do is create a new in app product and wait for few minutes and hit the API again.

Here is the code for NodeJS:

import { GoogleAuth } from "google-auth-library";

const client = new GoogleAuth({
  keyFile: "./sql-play-pk.json",
  scopes: "https://www.googleapis.com/auth/androidpublisher",
});

const packageName = "com.SqlPlay";
const productId = "premium";

const token = "your purchase token";

const purchaseUrl = `https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/purchases/products/${productId}/tokens/${token}`;

const res = await client.request({
  url: purchaseUrl,
});

console.log(res.data);

Upvotes: 0

Reyaz A. Beigh
Reyaz A. Beigh

Reputation: 3

I was also struggling with the permissions issue. I went ahead a assigned app specific permission to the service account user:

Click Manage link on the user and you will see the following section on the next page

After selecting the app and clicking apply, you need to add the following permission

I tested immediately after applying those permissions and it was not working. But came back next day and it was working fine.

Upvotes: 0

Wojciech Kulik
Wojciech Kulik

Reputation: 8500

There is one 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 must open "In-app products" and change something. You can for example edit the description of your product and save it. You should instantly get the permission then.

Upvotes: 257

BitQuestions
BitQuestions

Reputation: 760

For those who are still trying to find exactly where the permissions have to be set, once you already configured all the other things, you can reach that section following these steps:

  1. log to https://play.google.com/console
  2. click on "Users and permissions", then click on the email address that corresponds to the service account (or click on "Manage" to the right of it)
  3. click on tab "Account permissions".

As explained from previous comments, you only need to check "View app information and download bulk reports (read only)" and "View financial data, orders and cancellation survery responses", even if that makes no sense at all. Then wait for some hours, because not always the permissions get refreshed, even after following all the other suggestions. In my case, I waited overnight.

Upvotes: 0

Snuiper228
Snuiper228

Reputation: 31

Unfortunately for me, I didn't find the answer anywhere. The error still appeared. My problem got resolved when I changed the scope to: https://www.googleapis.com/auth/androidpublisher. This gives the correct OAuth credentials. After changing the scope, I started using the "purchases.subscriptionsv2.get" method (url: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}?access_token=your_access_token) instead of purchases.subscriptions.get (url:https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}?access_token=your_access_token) . It was somehow screwed up and now everything works! I hope I helped to someone

Upvotes: 0

Enakhi
Enakhi

Reputation: 1173

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.

Upvotes: 10

JT501
JT501

Reputation: 1705

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.

enter image description here

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. šŸŽ‰

Upvotes: 8

Shoaib Ahmed
Shoaib Ahmed

Reputation: 781

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

Upvotes: -3

Shivam Yadav
Shivam Yadav

Reputation: 1028

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

enter image description here

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

Happy Coding!

Upvotes: 7

Ankit Jindal
Ankit Jindal

Reputation: 4040

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

API-access

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

choose-project-link

1c. Agree to the terms and conditions

agree-terms-conditions

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

create-service-account

2b. Create Service account key credentials

service-account

2c. Enter details for service account

enter-service-account-details

2d. Download your JSON credential: json-credentials

3. Grant Access

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

grant-access

3b. Grant the following permissions:

apply-permissions

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.

Upvotes: 23

CanCoder
CanCoder

Reputation: 1150

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.

Upvotes: 0

ihsanberahim
ihsanberahim

Reputation: 2591

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.

Upvotes: 44

bikram
bikram

Reputation: 7985

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.

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

Upvotes: 90

gridsquare
gridsquare

Reputation: 183

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.

Upvotes: 17

panser
panser

Reputation: 2139

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

Upvotes: 2

Related Questions