【发布时间】:2017-10-26 08:51:38
【问题描述】:
我正在尝试使用 dropbox api 显示主列表文件夹,当我尝试从授权用户获取访问令牌时遇到很多问题。
我的代码很简单,我通过授予我的应用程序权限来获取代码。而获取token的请求是这样的。
$client = new GuzzleHttp\Client();
try{
// $response = $client->get("https://www.dropbox.com/oauth2/authorize?client_id=". $client_id . "&response_type=code");
$response = $client->post("https://api.dropboxapi.com/oauth2/token",
array(
'json' => array(
'grant_type' => 'authorization_code',
'code' => '********ZJtDI'
),
'auth' => array(
$client_id,
$client_secret
),
));
echo $response->getBody();
}catch ( \Exception $e ){
echo $e->getMessage();
}
Client error: `POST https://api.dropboxapi.com/oauth2/token` resulted in a `400 Bad Request` response:
{"error_description": "missing required field \"grant_type\"", "error": "invalid_request"}
【问题讨论】:
标签: php dropbox-api guzzle