swapnil chaudhari
swapnil chaudhari

Reputation: 81

Amazon SP API getting internal server error

I am trying to get access token from api https://api.amazon.com/auth/o2/token

POST /auth/o2/token HTTP/l.l
Host: api.amazon.com
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
grant_type=refresh_token
&refresh_token=Aztr|...
&client_id=foodev
&client_secret=Y76SDl2F

But after POST request I get 500 server error.

Is it because my app is in draft status? or I am missing something while making request?

If it because of draft status then when the status will get change? any thoughts on this.

Thank you for your help in advance.

Upvotes: 4

Views: 1718

Answers (2)

0xPeter
0xPeter

Reputation: 596

The documentation is wrong. I was getting the same exact error and came across this comment on a github issue which mentioned that the data has to be passed into the body of the request, not as query string parameters. Sure enough, this worked for me and I was able to get an access token. So just to clarify: grant_type, refresh_token, client_id, and client_secret should be passed into the body of the POST request to https://api.amazon.com/auth/o2/token and NOT as query string parameters.

Upvotes: 2

Kalani Ah Loy
Kalani Ah Loy

Reputation: 161

Draft status will not keep you from requesting and receiving the access token.

Here are a few things to check as not much can be derived from the example post request from the documentation:

  1. Did you configure AWS IAM role / policy / user properly
  2. Did you use the correct IAM ARN when registering the application
  3. Are you using the correct LWA credentials (I am assuming you're not passing foodev and Y76SDl2F as those are example parameters)
  4. Have you self authorized the application (are you using the refresh token generated for the authorized application)
  5. Are you 'assuming the role' before the token exchange -- this is a very important step and is very different in comparison to how access was handled with MWS -- if you have not, the server will reject the token exchange regardless if the refresh token is correct. More on that here

This is a non-exhaustive list, just some common issues I have seen other developers have with getting the access token during development, if these don't work you'll need to work with support as they can see the requests hitting the token endpoint.

Upvotes: 1

Related Questions