We're moving from Guzzle3 to Guzzle6. I wrote a process to authenticate and access the Azure Management API that worked fine in Guzzle3. However, I'm unable to figure out how to get it to work in Guzzle6. The purpose is to get the access token which is then use in subsequent requests to the Azure Management API.
Original Code:
$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);
New code I'm working on:
$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/',
)
)
);
I've tried so many variations with no luck. I would be grateful for any insight anyone could provide.
Thanks!