question

Mohamed Hassan avatar image
Mohamed Hassan asked

Can't get refresh code using the authorization code

I'm trying to get the refresh code using the authorization code as below

https://api.amazon.com/auth/o2/token?grant_type=authorization_code&code={}&client_id={}&client_secret={}&redirect_uri=https%3A%2F%2Fwww.test.com%2Fp%2Faccesstoken.html

However I got below error

{"error_description":"Malformed request","error":"invalid_request"}
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.

Levon@Amazon avatar image
Levon@Amazon answered

Hi there,

Thanks for posting! A couple of things:

  1. The request to exchange the auth code for refresh or access token has to be a POST request.
  2. I believe code_verifier needs to be a part of the request.

Here are the links to the LWA documentation for how to construct a request properly using the web API and SDK:

https://developer.amazon.com/public/solutions/devices/dash-replenishment-service/docs/dash-lwa-mobile-sdk

https://developer.amazon.com/public/solutions/devices/dash-replenishment-service/docs/dash-lwa-web-api

Hope this helps.

1 comment
10 |5000

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

Hi Levon,

I posted a question regarding the code_verifier parameter that might be pertinent to Mohammed's question:

https://forums.developer.amazon.com/questions/50343/is-the-code-verifier-parameter-mandatory-for-using.html

It does not show up in the sample code. Is there a reason for which it is omitted?

Cheers!

1 Like 1 ·
Mohamed Hassan avatar image
Mohamed Hassan answered

Thanks a lot for your reply.

It is a POST request already.

I don't know from where i can get the code_verifier. I tried to add random string as code_verifier however the same error returned to me.

1 comment
10 |5000

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