public function login()
    {
        $loginUrl = $this->credentials->getApiUrl() . '/json/access/ticket';
        $response = $this->httpClient->post($loginUrl, [
            'verify' => false,
            'exceptions' => false,
            'form_params' => [
                'username' => $this->credentials->getUsername(),
                'password' => $this->credentials->getPassword(),
                'realm' => $this->credentials->getRealm(),
            ],
        ]);

        $json = json_decode($response->getBody(), true);

        if (!$json['data']) {
            $error = 'Can not login using credentials: ' . $this->credentials;
            throw new AuthenticationException($error);
        }

        return new AuthToken(
            $json['data']['CSRFPreventionToken'],
            $json['data']['ticket'],
            $json['data']['username']
        );
    }