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

Access to requested resource is denied. #615

Open
SepuWeb opened this issue Sep 7, 2023 · 4 comments
Open

Access to requested resource is denied. #615

SepuWeb opened this issue Sep 7, 2023 · 4 comments

Comments

@SepuWeb
Copy link

SepuWeb commented Sep 7, 2023

Problem description:

Error:

errors": [ { "code": "Unauthorized", "message": "Access to requested resource is denied.", "details": "" } ] }

# Your error here. PLEASE make sure to redact secrets from your error log!

If I call VendorOrdersV1Api->getPurchaseOrders it works, so all security and rule and configuration are wright.

If I call these methods:
CatalogItemsV20220401Api->getCatalogItem
CatalogItemsV0Api->getCatalogItem
VendorDirectFulfillmentOrdersV20211228Api->getOrders

return the error:
{ "code": "Unauthorized", "message": "Access to requested resource is denied.", "details": "" }

Code

use Exception;
use Illuminate\Http\Request;
use SellingPartnerApi\Api\CatalogItemsV20220401Api;
use SellingPartnerApi\Api\VendorOrdersV1Api;
use SellingPartnerApi\Configuration;
use SellingPartnerApi\Endpoint;

class AmazonVendorController
{
 private function getConfiguration()
    {

        $config = new Configuration([
            "lwaClientId" => env('LWA_CLIENT_ID'),
            "lwaClientSecret" => env('LWA_CLIENT_SECRET'),
            "lwaRefreshToken" => env('LWA_REFRESH_TOKEN'),
            "awsAccessKeyId" => env('AWS_ACCESS_KEY_ID'),
            "awsSecretAccessKey" => env('AWS_SECRET_ACCESS_KEY'),
            "endpoint" => Endpoint::EU,
            "roleArn" => env('ROLE_ARN'),
        ]);

        return $config;
    }
$config = $this->getConfiguration();

        $apiInstance = new CatalogItemsV20220401Api($config);
        $marketplace_id = "APJ6JRA9NG5V4";
        
        try {
            $result = $apiInstance->getCatalogItem($marketplace_id, $asin);
            dd($result);
        } catch (Exception $e) {
            echo 'Exception when calling CatalogItemsV0Api->getCatalogItem: ', $e->getMessage(), PHP_EOL;
        }
}

Seller Central SP API config page screenshot

your screenshot here
image

@igormatkovic
Copy link

@SepuWeb did you ever get this sorted?

@SepuWeb
Copy link
Author

SepuWeb commented Oct 3, 2023

no, in the end I switched to the official Amazon SDK.

@da-mask
Copy link

da-mask commented Nov 14, 2023

This sucks. I'm having a similiar issue with calling createShippingLabels on createShippingVendorDirectFulfillmentShippingV20211228Api . Maybe something is broken with adding RDT's to requests? Are you registered as a Private Developer too?

I'd be nervous working on a PR too, as @jlevers doesn't seem to have looked at this repo in a few months.

@cguweb-com
Copy link

cguweb-com commented Mar 5, 2024

correct, gentlemen.. I am having the same permissions issue trying to use RDT.

I can actually get it to at least successfully generate and return an RDT now, but what am I supposed to do with it? Just simply calling a RDT report straight afterwards doesn't seem to automagically send the correct access token (the RDT) as I was hoping, so I am lost.

Do I need to generate the RDT, then somehow tell the SDK to use it instead of normal access token? Do I simply pass it in the config array?

in /lib/Authentication.php, there is the getRestrictedDataToken method I call to successfully generate the RDT, and it appears to just pass it back, so I am stuck with how to use it after generating :(

in official docs, it says the RDT needs to be passed in the x-amz-access-token header, in place of the usual LWA token - ok, but using this library, how do we do that???

any suggestions or solutions would be greatly appreciated!

thanks
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants