aporat / store-receipt-validator

PHP receipt validator for Apple iTunes, Google Play and Amazon App Store
Apache License 2.0
633 stars 153 forks source link

permissions issues #133

Closed Gameonn closed 4 years ago

Gameonn commented 4 years ago

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

Stafox commented 4 years ago

Absolutely clear error provided by api. Your service account should have permission to read financial information.

21 окт. 2020 г., в 22:00, Ankit Jindal notifications@github.com написал(а):

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Gameonn commented 4 years ago

But the account with which I have created service account and all other stuff has permissions to read financial data.

Stafox commented 4 years ago

image

Gameonn commented 4 years ago

Yes exactly the same permissions I have. Has this problem anything to do with in-app products?

My in-app products were already created and now I am setting up store validation API. But I have updated my in-app products and then regenerated the service account json keyfile.

Btw, here my code if anything is wrong over here:

        $googleClient = new \Google_Client();
        $scope = ['https://www.googleapis.com/auth/androidpublisher'];
        // $googleClient->setScopes([\Google_Service_AndroidPublisher::ANDROIDPUBLISHER]);
        $googleClient->setApplicationName('bulletforce');
        $googleClient->setScopes($scope);
        $pathToServiceAccountJsonFile = json_decode(Storage::disk('local')->get('keys/test.json'), true);
        $googleClient->setAuthConfig($pathToServiceAccountJsonFile);

        $validator = new PlayValidator(new \Google_Service_AndroidPublisher($googleClient));

        try {
          $response = $validator->setPackageName('com.blayzegames.iosfps')
              ->setProductId(PRODUCT_ID)
              ->setPurchaseToken(TEST_PURCHASE_TOKEN)
              ->validatePurchase();
        } catch (\Exception $e){
            echo $e->getMessage().PHP_EOL;
        }

Thanks

Stafox commented 4 years ago

It can take up to 36 hours for your Play Service Credentials to work properly with the Android Developer API.

Also make sure that service account connected with the app.

Gameonn commented 4 years ago

Yes the service account is linked with the app.

I was expecting it to work as soon as I generated the json key, but let's wait for 36 hours in order to check whether it works or not.

Thanks @Stafox

Gameonn commented 4 years ago

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

Please help me fix this.

Thanks

Stafox commented 4 years ago

Sorry, but I have no idea how to help. Time-to-time we got issues like yours connected with permissions. I just can recommend try to configure service account from scratch following these steps: https://docs.revenuecat.com/docs/creating-play-service-credentials

Gameonn commented 4 years ago

Thanks for the steps, i'll try this once more.

Besides your suggestion, I tried this as well https://stackoverflow.com/a/60691844/4198180, but it didn't work.

I shared my code last time, can you please review it once and see if there is something wrong in it?

Thanks

Stafox commented 4 years ago

The code looks fine.

Gameonn commented 4 years ago

@Stafox I was able to fix the permissions issue. But the bigger problem still prevails.

image

Here's what I get in response. But this response doesn't provides any information about the transaction like whether it was a valid transaction or not and other details.

Thanks

Stafox commented 4 years ago

It shouldn’t. I mean that correct response (without errors) from google api tells that transaction is valid. But to decide provide to user premium functionality or not you should by your own.

Regards

28 окт. 2020 г., в 8:19, Ankit Jindal notifications@github.com написал(а):

@Stafox I was able to fix the permissions issue. But the bigger problem still prevails.

Here's what I get in response. But this response doesn't provides any information about the transaction like whether it was a valid transaction or not and other details.

Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

johnkhansrc commented 3 years ago

@Gameonn

I was able to fix the permissions issue.

How did you solve the problem ? Is it just a matter of time ? (36 hours)