Using LwA on a website, trying to exchange the code for access and refresh tokens through a backend call to https://api.amazon.com/auth/o2/token, we’re getting an error (400 status) response :
{
"error_index": "...",
"error_description": "The request has an invalid grant parameter : redirect_uri",
"error": "invalid_grant",
"request_id": "..."
}
The documentation says that the redirect_uri is mandatory in the request, presumably so that LwA could compare it with the one used when issuing the code. We’ve double checked that the value of the redirect_uri is correct and identical in the authorization and the exchange, url-encoded properly, the request content type is indeed application/x-www-form-urlencoded and contains just grant_type=authorization_code as well as the code, client id and secret and the redirect_uri, which is included in the security profile “allowed return URLs”.
What other reasons could there be for this error?