public function login($tgtStorageLocation = '', $forceAuth = false)
    {

        if ((!$this->casServer) || (!$this->casPassword) || (!$this->casUsername)) {
            throw new \Exception('CAS server and credentials must be set before calling login()', 1);
        }

        $this->tgtStorageLocation = $tgtStorageLocation;

        // Try to load the TGT from the storage file
        if (!$forceAuth && $tgtStorageLocation) {
            if (file_exists($tgtStorageLocation)) {
                if (! is_readable($tgtStorageLocation)) {
                    throw new \Exception('TGT storage file [' . $tgtStorageLocation . '] is not readable!', 500);
                }
                $this->loadTGTfromFile($tgtStorageLocation);
                return true;
            }
        }

        try {
            $response = $this->guzzleClient->request(
                'POST',
                $this->casRESTcontext,
                [
                    'verify' => $this->verifySSL,
                    'form_params' => [
                        'username' => $this->casUsername,
                        'password' => $this->casPassword
                    ]
                ]
            );

            $responseHeaders = $response->getHeaders();

        } catch (ClientException $e) {
            // Bad username or password.
            if ($e->getCode() == 400) {
                return false;
                // Unsupported Media Type
            } elseif ($e->getCode() == 415) {
                return false;
            } else {
                throw new \Exception($e->getMessage(), $e->getCode());
            }
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage(), $e->getCode());
        }

        if (isset($responseHeaders['Location'][0])) {
            $this->tgtLocation = $responseHeaders['Location'][0];
            $this->tgt = substr(strrchr($this->tgtLocation, '/'), 1);
        }

        // Save the TGT to a storage file.
        if ($tgtStorageLocation) {
            $this->writeTGTtoFile($tgtStorageLocation, $this->tgt);
        }

        return true;
    }