-
Notifications
You must be signed in to change notification settings - Fork 121
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
Keep getting Unauthorized using sample requests #1
Comments
Hi there, yes, it works for us and it should work for you as well and return a reportId. Looks like your are not authorized, but error messages from Amazon are currently not very helpful for some calls. |
Hey, thanks for the quick reply. require("dotenv").config();
require("source-map-support").install();
import SellingPartnerAPI from "amazon-sp-api";
(async () => {
try {
const sellingPartner = new SellingPartnerAPI({
region: "na",
refresh_token:
"Atzr|IXXXXXXX",
options: {
auto_request_tokens: true,
auto_request_throttled: true,
},
});
await sellingPartner.refreshAccessToken();
console.log(sellingPartner.access_token);
await sellingPartner.refreshRoleCredentials();
console.log(sellingPartner.role_credentials);
let res = await sellingPartner.callAPI({ operation: "getMarketplaceParticipations" });
console.log(res);
} catch (e) {
console.log(e);
}
})(); Does that mean I'm authed as a
|
Since you receive access_token and security_token the credentials seem to be correct, yes. Have you checked that you are using the correct IAM role and that it has access to the sellingpartner API? If yes, I'm afraid I'm running out of ideas. :-) One more idea: Since you created a new seller account, have signed up to a professional selling plan? I know at least for the old MWS API it a a requirement to have a professional plan so I would guess its a requirement for access to the SP API as well. |
Same error as before :/ Are there any other basic requests I could try other than await sellingPartner.callAPI({ operation: "getMarketplaceParticipations" })? |
You could try the catalog item calls, i.e.:
|
Unfortunately still getting |
We haven't built in any debugging possibility yet, but you could log the request and result objects in lib/request.js, maybe this might help you in resolving the issue. |
Did you follow steps 1 to 6 listed here? Did you do anything else to get it working? I'm wondering if their docs are missing a step. |
Yes, just followed the steps. Only information missing in the guide is how to add the security_token, but thats handled inside our client. For the IAM ARN of your app client in sellercentral, did you make sure you put the IAM role created in step 4? |
I believe I just created everything in my default AWS Region does that make a difference? Or did you mean Will go over the other items again now. UPDATE: And yes Key + Secret are from User created in Step 2 |
Hm, I'm afraid I'm running out of ideas here. Might be something with the region, as we tested with the EU region and not the NA region, but only the API endpoint subdomains and the region for signing the requests are different and both is implemented and working. So probably the best chance is to log the response headers of a failing request, copy the Request-ID returned ("x-amzn-requestid"-Header), open up a case with the SP/MWS-Team at Amazon and send them the Request-ID. |
FWIW, I can confirm I was able to use this package in NA using the instructions in the README. |
@tday Thanks for clarifying. Must be something up with my amazon account then. |
@amz-tools So just to be 100% certain here are my regions.
How should I be configuring the region settings / configurations. |
@StevenJE The region setting depends on the marketplace you want to request data from, not the region you registered in. Since you have access to the North America selling region (US, Canada, Mexico) you can use "na" as region. |
@StevenJE it's worth reaching out to Amazon to see if they gave you access correctly if all things check out on your end. Amazon had notified us on two separate occasions we had access, but we in fact did not. We had to escalate three times to Amazon before they gave us proper access. |
@StevenJE Can you please try below request? let res = await sellingPartner.callAPI({ I'm having the same unauthorized issue but I was able to use the API with the above request without any problem. Seems like it has an issue with your Developer Profile Auths. |
Hey @metecicek unfortunately the account I have is purely for development so it has no products or orders, so I don't think I can do the request as it would be lacking an order number. |
Hey @metecicek, I have been getting the same 403 unauthorised error and can confirm that this getOrder API call also worked for me. I have an open case with amazon support but let me know if you ever get to the bottom of it as so far they have been pretty useless. |
@callumb123 how did you open a support request with them? When I tried to open a request in seller central everything seemed very focused around sellers. Is there a way to get dev support? Also any responses in the interim on your end from amazon? Would love to get this fixed. |
@StevenJE I'm based in the UK so I used this link: https://sellercentral.amazon.co.uk/gp/mws/contactus.html My first case got picked up by someone who was no help at all and didn't understand the question so I have had to submit a new ticket. I have had one response where they have told me the LWA details I have used in the request are wrong and to double check them. I'm fairly sure they aren't (since the getOrder endpoint works) so have asked for more information on which details they think are wrong. I will update here again if I get to the bottom of it as I am also pretty desperate to get this working. |
@metecicek any updates on your end? |
@callumb123 thanks! Yeah me too, I'm burning cash paying for access with nothing working. Will update also. |
Hey @callumb123 I just tried re-running my code and now everything has started working... guessing it was something amazons side that they have now fixed. try running this. let res2 = await sellingPartner.callAPI({ operation: "getMarketplaceParticipations" });
console.log(res2); |
@StevenJE Awesome! Just tested a few endpoints there and they all seem to be working. I would be really curious to find out what was wrong as Amazon's end to affect so many people. Thanks a lot for letting me know, much appreciated! |
This is weird, as I just hit this issue with an app that was already working yesterday!. Ah, the perks of being a dev. Works one day, and it mysteriously stops working the next. Have raised a ticket, let's see what they say. |
So, on further testing, found the following:
020-12-26T12:51:26.034Z fa99489f-358c-4d9e-a07d-ec94d104a2fe INFO CustomError: Access to requested resource is denied. |
I got the same "Access to requested resource is denied" issue. Does it work for the vendor central account, also? |
Hi @pavel-labbmiljo, we haven't tested it, maybe somebody else is here who can confirm it works. It should work, but it seems that vendors have a subset of operations of the SP API available, found this blog post here, maybe that helps. |
So this |
Keep getting
Unauthorized
error using sample requests in docs. Should these examples work?I'm trying to work out if I'm not authenticating properly or whether the API endpoint is giving the error as I'm trying to request data that I don't have access to (as it's your data)
Using a brand new marketplace seller account / no products / data.
The text was updated successfully, but these errors were encountered: