'message': 'Access to requested resource is denied.', 'code': 'Unauthorized' issue
See original GitHub issueI 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:
- Created 3 years ago
- Comments:34 (17 by maintainers)
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!
@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.