Deishelon / google-play-billing-validator

Npm module for Node.js to validate In-app purchases and Subscriptions on your backend
https://medium.com/androidhub/how-to-validate-in-app-purchase-subscription-on-your-node-js-backend-a2b823470034
90 stars 32 forks source link

Error 401 - insufficient permissions #22

Open daniely-93 opened 3 years ago

daniely-93 commented 3 years ago

I've set up a service account and linked it to Google Play, granted all the permissions including "View financial data" under "API Access" page.

{
    "isSuccessful": false,
    "errorCode": 401,
    "errorMessage": "The current user has insufficient permissions to perform the requested operation."
}

When I am trying to verify a purchase, it throws error 401 even though I been waiting 24 hours maybe until Google servers update. When I call this get API with OAuth2 token, it works so the account has the permissions: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.my.package/purchases/products/<productId>/tokens/<purchaseToken>

Relevant code:

const Verifier = require("google-play-billing-validator");

const gpOptions = {
  email: gAccount.client_email,
  key: gAccount.private_key,
};

const verifier = new Verifier(gpOptions);

app.post("/verify", async (req, res) => {
  const { productId, purchaseToken } = req.body;
  verifier
    .verifyINAPP({
      productId,
      purchaseToken,
      packageName: "com.my.package",
    })
    .then((res) => res.status(200).json({ res }))
    .catch((error) => {
      res.status(500).send({
        success: false,
        error,
      });
    });
});

permissions

ghost commented 3 years ago

Hi ! Found out the answer here: https://stackoverflow.com/questions/43536904/google-play-developer-api-the-current-user-has-insufficient-permissions-to-pe

sandesh-bhoir commented 11 months ago

Hi ! Found out the answer here: https://stackoverflow.com/questions/43536904/google-play-developer-api-the-current-user-has-insufficient-permissions-to-pe

is this verified solution?

sandesh-bhoir commented 11 months ago

@daniely-93 did you found a solution on this issue, I tried the stackoverflow solution but still the error persists.

sandesh-bhoir commented 11 months ago

It took me a waiting time for about 24 hours to get the permissions reflected. Modifying the subscription data didn't helped in force reflecting the permission changes. At the end it worked.

premj-ekah commented 8 months ago

Hi @daniely-93 @sandesh-bhoir, I'm getting the same issue even after 24 hours. Did you found a solution on this issue?

sandesh-bhoir commented 8 months ago

Hi @daniely-93 @sandesh-bhoir, I'm getting the same issue even after 24 hours. Did you found a solution on this issue?

The service account you had created needs to be added in https://play.google.com with the respective permissions as shared in screen above.

premj-ekah commented 8 months ago

Hi @sandesh-bhoir where to add service account in google play console, can you please share a link for google play console?

sandesh-bhoir commented 8 months ago

Hi @sandesh-bhoir where to add service account in google play console, can you please share a link for google play console?

They have mentioned steps in documentation. Do check step 4.

premj-ekah commented 8 months ago

Okay Thanks for your time!