【发布时间】:2018-04-09 23:15:03
【问题描述】:
我正在使用以下代码从使用 OpenID 协议的 IdentityServer 请求令牌:
$curl = curl_init( 'https://remoteserver.com/connect/token' );
curl_setopt( $curl, CURLOPT_POST, true );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);
$code = $_GET['code']; // The code from the previous request
$redirect_uri = 'http://mycalldomain.com/test.php';
curl_setopt( $curl, CURLOPT_POSTFIELDS, array(
'redirect_uri' => $redirect_uri,
'grant_type' => 'authorization_code'
) );
curl_setopt( $curl, CURLOPT_USERPWD,
"MYCLIENTID" . ":" .
"MYCLIENTSECRET");
$auth = curl_exec( $curl );
print '$auth = ';print_r($auth); // to see the error
$secret = json_decode($auth);
$access_key = $secret->access_token;
正在输出以下错误:
$auth = {"ErrorMessage":"Unsupported Mediatype"}
有人可以指导一下吗?
【问题讨论】:
标签: php curl oauth openid identityserver3