1
我們正在從Guzzle3移動到Guzzle6。我編寫了一個過程來驗證和訪問在Guzzle3中正常工作的Azure Management API。但是,我無法弄清楚如何在Guzzle6中使用它。其目的是獲取訪問令牌,然後在Azure Management API的後續請求中使用該令牌。使用Guzzle6獲取Azure令牌時出現問題(錯誤:AADSTS90014)
原始代碼:
$client = new Guzzle\Http\Client();
$request = $client->post("https://login.microsoftonline.com/{$tenant_id}/oauth2/token",
Array(
'Accept' => 'application/json',
),
Array(
'grant_type' => 'client_credentials',
'client_id' => $application_id,
'client_secret' => $application_secret,
'resource' => 'https://management.core.windows.net/',
)
);
$response = $request->send();
$body = $response->getBody(true);
新的代碼我工作:
$client = new GuzzleHttp\Client();
$response = $client->request(
'POST',
"https://login.microsoftonline.com/{$tenant_id}/oauth2/token",
Array(
GuzzleHttp\RequestOptions::JSON => Array(
'grant_type' => 'client_credentials',
'client_id' => $application_id,
'client_secret' => $application_secret,
'resource' => 'https://management.core.windows.net/',
)
)
);
我已經試過,沒有運氣這麼多的變化。我會很感激任何人都可以提供的見解。
謝謝!