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']
        );
    }
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']
        );
    }
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' ] ) ; }
Attempts to login using set credentials, if succeeded will return the
AuthToken used in all requests.

@return \ProxmoxVE\AuthToken When successful login will return an
instance of the AuthToken class.

@throws \ProxmoxVE\Exception\AuthenticationException If login fails.
Attempts to login using set credentials if succeeded will return the AuthToken used in all requests .