【发布时间】:2017-09-04 03:25:04
【问题描述】:
我正在尝试使用 uber rush api 验证我的身份,但我不断收到 unsupported_grant_type 错误消息。我不确定我在这里做错了什么。任何帮助将非常感激。下面是我正在使用的代码
下面是命令行请求的样子:
curl -F "client_secret=<CLIENT_SECRET>" \
-F "client_id=<CLIENT_ID>" \
-F "grant_type=client_credentials" \
-F "scope=delivery" \
https://login.uber.com/oauth/v2/token
这是我用 PHP 编写的方法
$cl = curl_init("https://login.uber.com/oauth/v2/token");
curl_setopt($cl,CURLOPT_POST,["client_secret"=>"********"]);
curl_setopt($cl,CURLOPT_POST,["client_id"=>"**********"]);
curl_setopt($cl,CURLOPT_POST,["grant_type"=>"client_credentials"]);
curl_setopt($cl,CURLOPT_POST,["scope"=>"delivery"]);
$content = curl_exec($cl);
curl_close($cl);
var_dump($content);
【问题讨论】:
-
您使用了错误的选项来设置 POST 参数。在文档中搜索
CURLOPT_POST,此处为:php.net/manual/en/function.curl-setopt.php。您会看到它需要一个布尔值来指示请求是否应使用POST方法。
标签: php curl oauth-2.0 uber-api