小编Gev*_*ebf的帖子

从亚马逊获取“授权服务器不支持授权授予类型”

我正在尝试获取访问令牌,否,我遇到此错误

{“ error_description”:“授权服务器不支持授权授予类型”,“ error”:“ unsupported_grant_type”}

$code =  $_GET['code'];

$postfields = array(
    'grant_type'=>'authorization_code',
    'code'=>$code,
    'redirect_uri='=>'example/myTest.php',
    'client_id'=>'amzn1.application-oa2-client.xxxxxxxxxxx',
    'client_secret'=>'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.amazon.com/auth/o2/token');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($httpRequest, CURLOPT_HEADER, 1);
// Edit: prior variable $postFields should be $postfields;
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!
$result = curl_exec($ch);

print_r($result);
Run Code Online (Sandbox Code Playgroud)

php curl amazon amazon-web-services

5
推荐指数
2
解决办法
3200
查看次数

标签 统计

amazon ×1

amazon-web-services ×1

curl ×1

php ×1