question

shaqspeare avatar image
shaqspeare asked

Error calling /auth/o2/token: The Content-Type is not supported by the auth

[On behalf of: Infofinity] Hi, I'm passing in a Content-Type header of application/x-www-form-urlencoded, but the /auth/o2/token API keeps giving me: DEBUG - << "{"error":"invalid_request","error_description":"The Content-Type is not supported by the authorization server"}" I'm running from Java and here are the full HttpClient request and response bodies with headers (also notice that it looks like Amazon has a bug in naming its "nnCoection" response header): DEBUG - Get connection for route {s}-> https://api.amazon.com DEBUG - Connecting to api.amazon.com:443 DEBUG - Sending request: POST /auth/o2/token HTTP/1.1 DEBUG - >> "POST /auth/o2/token HTTP/1.1\r\n" DEBUG - >> "Content-Type: application/x-www-form-urlencoded;charset=UTF-8\r\n" DEBUG - >> "Content-Length: 290\r\n" DEBUG - >> "Host: api.amazon.com\r\n" DEBUG - >> "Connection: Keep-Alive\r\n" DEBUG - >> "\r\n" DEBUG - >> "redirect_uri=https%3A%2F%2F{...REMOVED...}&client_id={...REMOVED...}&code={...REMOVED...}&client_secret={...REMOVED...}&grant_type=authorization_code" DEBUG - Receiving response: HTTP/1.1 400 Bad Request DEBUG - << HTTP/1.1 400 Bad Request DEBUG - << Date: Wed, 28 Aug 2013 07:18:24 GMT DEBUG - << x-amzn-RequestId: 06cfe509-0fb2-11e3-b47c-a1f95ca4d840 DEBUG - << Content-Type: application/json DEBUG - << Content-Length: 111 DEBUG - << Vary: Accept-Encoding,User-Agent DEBUG - << nnCoection: close DEBUG - Connection can be kept alive indefinitely DEBUG - << "{"error":"invalid_request","error_description":"The Content-Type is not supported by the authorization server"}"
login with amazon
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shaqspeare avatar image
shaqspeare answered
The /auth/o2/token endpoint does not support the charset parameter in the Content-Type header. If you set the Content-Type header specifically to "application/x-www-form-urlencoded" you should no longer receive this error.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shaqspeare avatar image
shaqspeare answered
[On behalf of: Infofinity] Hi Annabelle, thanks for your response, but I got the same error without the charset. In fact, I only added charset because it is in the Amazon documentation here: https://developer.amazon.com/sdk/adm/token.html Wherein it states that POST /auth/O2/token has a Charset in the Content-Type.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shaqspeare avatar image
shaqspeare answered
That appears to be an error in the sample request on that page; the header description table below the sample request correctly states that the Content-Type must be "application/x-www-form-urlencoded". Could you run your request through curl with the "--verbose" option on and send the result to us at lwa-support@amazon.com, with your client secret redacted?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.