public function authenticate(IRequest $request)
    {
        $id = $request->request('client_id');
        $secret = $request->request('client_secret');

        if (!$id) {
            throw new InvalidClientException('Client id is missing.');
        }

        if (!$client = $this->clientStorage->get($id)) {
            throw new InvalidClientException('Invalid client credentials.');
        }

        if ((string) $secret !== (string) $client->getSecret()) {
            throw new InvalidClientException('Invalid client credentials.');
        }

        return $client;
    }