Seller Central
Seller Forums

Amazon Seller Forums » Login With Amazon » Login With Amazon Developers

Thread: unsupported_grant_type error
Thread Archived This thread has been archived - replies are not allowed.

This question is answered.

Permlink Replies: 1 - Pages: 1 - Last Post: 21 Mar, 2017 5:06 PM by: Pulkit M (LWA) Threads: [ Previous | Next ]

Posts: 1
Registered: 20 Mar, 17 1:34 AM
Posted on: 19 Mar, 2017 7:00 PM  
Click to report abuse...
We keep getting "unsupported_grant_type - The authorization grant type is not supported by the authorization server" error message when we try to get access token.

code request url is "***&redirect_uri=***"

then, my script is:

$code = $_GET;
$header[1] = "Content-Type:application/x-www-form-urlencoded;charset=UTF-8";
$url = '';
$params = array(
"code" => $code,
"client_id" => "amzn1.application-oa2-client.***",
"client_secret" => "***",
"redirect_uri" => "***",
"grant_type" => "authorization_code"
$curl = curl_init( $url );
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$json_response = curl_exec($curl);

Where do I do wrong?

Edited by: MG-Developer on Mar 19, 2017 7:01 PM
Is this a helpful question? Yes 0   No
1 Reply
Sort replies by:
Pulkit M (LWA)

Posts: 31
Registered: 11 Aug, 14 4:57 PM
Posted on: 21 Mar, 2017 5:06 PM   in response to: MG-Developer in response to: MG-Developer  
Click to report abuse...
I was successfully able to execute the following cURL request to get an access token and refresh token:

curl -k -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d "grant_type=authorization_code&code=<authorization-code>&redirect_uri=<your-redirect-uri>&client_id=<your-client-id>&client_secret=<your-client-secret>" ''

Because you are using Content-Type:application/x-www-form-urlencoded;charset=UTF-8, I believe that $params being passed in CURLOPT_POSTFIELDS must be like they would be in a URL (hence the urlencoded).

Can you try passing the following instead of $params? Replace the fillers with your application details.
Was this reply helpful? Yes 0   No 0