GiakAdi
GiakAdi

Reputation: 3

Symfony 5 httpClient Windows AD connection

Is it possible to connect to an API with windows Credentials? I need to connect on an API witch uses Windows AD authentication. I thought thats works with auth_basic but it's not the good way...

Thanks by advance for your answers

$httpClient = HttpClient::create([
  'auth_basic' => ['username', 'password']
]);
$response = $httpClient->request('GET', 'https://apiURL', [
  'headers' => ['accept' => 'text/plain'],
]);
dump($response->getStatusCode());
dump($response);

Upvotes: 0

Views: 321

Answers (1)

Emanuele
Emanuele

Reputation: 617

Yes, it's possibile using the auth_ntlm option. But this option is supported only by the cURL client, so you must have the cURL PHP extension installed and enabled in your system. Here's the code:

$httpClient = new CurlHttpClient(['auth_ntlm' => "username:password"]);
$response = $httpClient->request('GET', 'https://apiURL', [
  'headers' => ['accept' => 'text/plain'],
]);
dump($response->getStatusCode());
dump($response);

Upvotes: 0

Related Questions