google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

insert product using google-api-php-client

Open nandaks opened this issue 1 year ago • 1 comments

$this->api_client_obj->addScope('https://www.googleapis.com/auth/androidpublisher'); $service = new Google_Service_AndroidPublisher($this->api_client_obj);

    $body = new Google_Service_AndroidPublisher_InAppProduct();
    $body->setSku($data['sku']);
    $body->setPackageName($data['packageName']);
    $body->setStatus($data['status']);
    $body->setPurchaseType($data['purchaseType']);
    
    // $1.00 USD = 1,000,000 Microns.
    $price = new Google_Service_AndroidPublisher_Price();
    $price->setCurrency('INR');
    $price->setPriceMicros($data['defaultPrice']['priceMicros']);
    $body->setDefaultPrice($price);
    
    $body->setDefaultLanguage($dat['defaultLanguage']);
    $body->setListings([
        'en_US' => [
            'title' => $data['listings']['en-US']['title'],
            'description' => $data['listings']['en-US']['description']
        ]
    ]);
    $purchase = $service->inappproducts->insert($data['packageName'], $body, [
        'autoConvertMissingPrices' => true,
    ]);

I am getting { "error": { "code": 403, "message": "The caller does not have permission", "errors": [ { "message": "The caller does not have permission", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED" } }

Please help me

nandaks avatar Feb 22 '24 12:02 nandaks

Hi @nandaks Thanks for filling the issue.

Could you please verify that you're using the correct account for authentication and that the account has the relevant permissions because the error is definitive enough to say that there is a problem with the permissions.

You could try inserting the product using the REST API reference to verify.

If you want more information on the authentication, please read this section from the readme.

saranshdhingra avatar Mar 07 '24 14:03 saranshdhingra

Hi @nandaks I'll be closing this issue for now, but if you have more to discuss, please feel free to reopen it.

saranshdhingra avatar May 23 '24 06:05 saranshdhingra