question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'message': 'Access to requested resource is denied.', 'code': 'Unauthorized' issue

See original GitHub issue

I have been getting this error for every request. I currently have a Seller Central account and I am trying to gain access to the api. I have followed the documentation provided by amazon to set up the necessary credentials, but still receive the ‘Access to requested resource is denied.’ error message. I have checked in on the access_token that is being generated and it matches the ‘Atza|xxxxxx’ format, so I do not believe that is the issue.

Additionally, I have been following the Self Authorization guidelines to get the refresh token used here, so I am unsure as to why I am getting the error.

I have searched through the issues here and under the Seller-partner-api-docs and found no solution.

from sp_api.api.orders.orders import Orders

os.environ["SP_API_REFRESH_TOKEN"] = "Atzr|xxxxxxxx"
os.environ["LWA_APP_ID"] = "amzn1.application-oa2-client.xxxxxxxx"
os.environ["LWA_CLIENT_SECRET"] = "xxxxxxxx"
os.environ["SP_API_SECRET_KEY"] = "xxxxxxxx"
os.environ["SP_API_ACCESS_KEY"] = "xxxxxxxx"
os.environ["SP_API_ROLE_ARN"] = "arn:aws:iam::xxxxxxxx:role/SellerPartnerAPIRole"
os.environ["SP_AWS_REGION"] = "us-east-1"

try:
    res = Orders().get_orders(CreatedAfter=(datetime.datetime.utcnow() - datetime.timedelta(days=7)).isoformat())
    print(res.payload)  # json data
except SellingApiException as ex:
    print(ex)

output {‘Date’: ‘Wed, 27 Jan 2021 15:22:51 GMT’, ‘Content-Type’: ‘application/json’, ‘Content-Length’: ‘141’, ‘Connection’: ‘keep-alive’, ‘x-amzn-RequestId’: ‘387bf5b0-58c6-4dee-93a0-47c3da1fadc0’, ‘x-amzn-ErrorType’: ‘AccessDeniedException’, ‘x-amz-apigw-id’: ‘Z0HDvHjOoAMF0Aw=’} {‘errors’: [{‘message’: ‘Access to requested resource is denied.’, ‘code’: ‘Unauthorized’, ‘details’: ‘’}]} [{‘message’: ‘Access to requested resource is denied.’, ‘code’: ‘Unauthorized’, ‘details’: ‘’}]

Any help will be greatly appreciated!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:34 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
t-wittkopfcommented, Feb 11, 2021

I encountered the same error. The solution for me was to switch to the correct Marketplace in the client. I tried calling the DE marketplace but default in the client is the US marketplace. So if you have registered your app to another marketplace than US then you have to edit the client. At least that worked for me. Also thanks for this great wrapper btw Michael!

1reaction
saleweavercommented, Feb 11, 2021

@ritik-novostack Your settings seem to be correct, at least where you put which value. Your credentials look like you’ve tried to create at least the role multiple times; to figure out if there’s a problem with permissions, or if your app registration in sellercentral is correct, I’d need more information. Maybe just try to start from scratch and create a set of new user, role, … as in Amazon’s docs, create a new app and try with that. It’s very important to follow the guide closely.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unauthorized, Access to requested resource is denied #290
I have been trying to use Amazon SP-API recently but somehow I am getting Unauthorized message. Confirmed that my AWS IAM role has...
Read more >
Access to requested resource is denied 403 SP-API ...
To solve the problem I created a new app using the Rol ARN instead of the User ARN. Like this: enter image description...
Read more >
SP-API: 'Access to requested resource is denied'
Hello, I'm having some trouble getting my first SP-API request to work. ... message: 'Access to requested resource is denied.', code: 'Unauthorized',
Read more >
SP-API - Access to requested resource is denied
We are trying to develop a private application to create and print Amazon shipping labels, but we are running into issues when trying...
Read more >
access to requested resource is denied - Forums
So, do we need an active Amazon Seller account to access Selling-Partner API? ... "message": "Access to requested resource is denied.",
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found