3
3
namespace Slakbal \Citrix ;
4
4
5
5
use GuzzleHttp \Client as HttpClient ;
6
+ use GuzzleHttp \ClientInterface ;
6
7
7
8
class DirectAuthenticate
8
9
{
@@ -21,7 +22,7 @@ class DirectAuthenticate
21
22
22
23
protected $ client_id ;
23
24
24
- protected $ http_client ;
25
+ protected $ client ;
25
26
26
27
protected $ response ;
27
28
@@ -33,13 +34,11 @@ public function __construct()
33
34
$ this ->username = config ('citrix.direct.username ' );
34
35
$ this ->password = config ('citrix.direct.password ' );
35
36
$ this ->client_id = config ('citrix.direct.client_id ' );
36
-
37
- $ this ->http_client = new HttpClient ([
37
+ $ this ->client = new HttpClient ([
38
38
'base_uri ' => $ this ->base_uri ,
39
39
'timeout ' => $ this ->timeout ,
40
40
'verify ' => $ this ->verify_ssl ,
41
41
]);
42
-
43
42
}
44
43
45
44
@@ -52,6 +51,15 @@ public function authenticate()
52
51
'client_id ' => $ this ->client_id ,
53
52
];
54
53
54
+ if (version_compare (ClientInterface::VERSION , '6 ' ) === 1 ) {
55
+ $ options = ['form_params ' => $ params ];
56
+ } else {
57
+ $ options = ['body ' => $ params ];
58
+ }
59
+
60
+ $ this ->response = $ this ->client ->post ('/oauth/access_token ' , $ options );
61
+
62
+ /*
55
63
$this->response = $this->http_client->get('/oauth/access_token', [
56
64
'header' => [
57
65
'Content-Type' => 'application/x-www-form-urlencoded',
@@ -60,7 +68,7 @@ public function authenticate()
60
68
'query' => $params,
61
69
'form_params' => $params,
62
70
]);
63
-
71
+ */
64
72
// 'headers' => [
65
73
// 'Content-Type' => 'application/x-www-form-urlencoded',
66
74
// 'Accept' => 'application/json',
@@ -80,7 +88,6 @@ public function authenticate()
80
88
81
89
$ this ->statusCode = $ this ->response ->getStatusCode ();
82
90
83
-
84
91
$ this ->response = $ this ->response ->getBody ();
85
92
86
93
//dd( (string)$this->response );
0 commit comments