0
這使我瘋狂!PHP Microsoft Azure oauth2令牌POST方法不起作用
如果方法是POST,爲什麼Azure返回「AADSTS90056:此端點只接受POST,OPTIONS請求,接收到GET請求」錯誤?
代碼:
$url='http://login.microsoftonline.com/common/oauth2/v2.0/token';
$data = array('code'=>$code,'resource'=>$resource,'redirect_uri' => $redirect_uri, 'client_id' => $client_ID, 'scope' => $scope, 'grant_type' => $grant_type, 'client_secret' => $client_secret);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
你能檢查你的網絡調用,看看發送的請求是否實際上是一個POST? –