Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert product using google-api-php-client #2567

Closed
nandaks opened this issue Feb 22, 2024 · 2 comments
Closed

insert product using google-api-php-client #2567

nandaks opened this issue Feb 22, 2024 · 2 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@nandaks
Copy link

nandaks commented Feb 22, 2024

$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

@saranshdhingra saranshdhingra self-assigned this Mar 7, 2024
@saranshdhingra saranshdhingra added the type: question Request for information or clarification. Not an issue. label Mar 7, 2024
@saranshdhingra
Copy link
Contributor

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
Copy link
Contributor

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

@saranshdhingra saranshdhingra removed their assignment May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants