diff --git a/src/ElixForms/Auth/ElixFormsAuthenticationClient.php b/src/ElixForms/Auth/ElixFormsAuthenticationClient.php index 4740e79..53cc627 100644 --- a/src/ElixForms/Auth/ElixFormsAuthenticationClient.php +++ b/src/ElixForms/Auth/ElixFormsAuthenticationClient.php @@ -23,12 +23,15 @@ class ElixFormsAuthenticationClient { * @throws ElixFormsException Se le credenziali sono errate o c'รจ un errore server */ public function login(string $username, string $password): string { - $this->baseUrl = rtrim($this->baseUrl,'/'); $url = "{$this->baseUrl}/services/api/authentication/login/v1"; try { $response = $this->httpClient->post($url, [ - 'form_params' => [ + 'headers' => [ + 'x-requested-with' => 'XMLHttpRequest', + 'Content-Type' => 'application/json' + ], + 'json' => [ 'username' => $username, 'password' => $password ] @@ -70,7 +73,7 @@ class ElixFormsAuthenticationClient { try { $response = $this->httpClient->post($url, [ 'headers' => [ - 'Authorization' => 'Bearer ' . $token, + 'Authorization' => "Bearer {$token}", 'Content-Type' => 'application/x-www-form-urlencoded' ] ]);