0
我給這個作爲一個例子:創建使用PHP適當的授權請求,捲曲
Request example 1:
POST /v1/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Accept: application/json
grant_type=client_credentials&client_id=test&client_secret=abc123
我使用PHP /捲曲嘗試這個。
我曾嘗試:
$url = "someUrl";
$ch = curl_init();
$username = "someUser";
$password = "somePass";
$post = json_encode(array(('grant_type'=>'client_credentials'));
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
卻得到一個錯誤: 「錯誤」: 「unsupported_grant_type」
什麼是正確的格式?
我應該使用計算器? – bart2puck
我的瀏覽器截斷了你評論的最後部分。謝謝 – bart2puck