我通过使用以下命令在命令行中获得了我想要的(令牌)(但在php中需要它):
curl -d "client_id=theClient" -d "grant_type=password" "https://auth.theClient.de/auth/openid-co/token"
然后我尝试在PHP中实现它:
<?php
$requestURL = 'https://auth.theClient.de/auth/openid-co/token';
$postData = "grant_type=password&client_id=theClient&scope=openid";
$headers[0] = 'Content-Type: application/x-www-form-urlencoded';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $requestURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$response = curl_exec($ch);
$responseArray = json_decode($response, TRUE);
var_export($responseArray);
应该给我令牌,但是我收到错误的请求并做出回应:
array (
'error_description' => 'X509 client certificate is missing.',
'error' => 'invalid_request',
)
我将证书导入了Chrome Webbrowser(“设置”>“高级”)。
我假设在apache网络服务器或php脚本(p12-keystore)中的配置中缺少证书。