gpt4 book ai didi

php - 从亚马逊获取 "The authorization grant type is not supported by the authorization server"

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:40:39 32 4
gpt4 key购买 nike

我正在尝试获取访问 token ,但是我收到了这个错误

{"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);

最佳答案

更改 CURLOPT_HTTPHEADER

内容类型:application/x-www-form-urlencoded

内容类型:application/json

关于php - 从亚马逊获取 "The authorization grant type is not supported by the authorization server",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40606147/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com