/**
* Validate a client. If strictly validating an ID and secret are required.
*
* @param bool $strict
* @return \Dingo\OAuth2\Entity\Client
* @throws \Dingo\OAuth2\Exception\ClientException
*/
protected function validateClient($strict = false)
{
// Grab the redirection URI from the post data if there is one. This is
// sent along when validating a client for some grant types. It doesn't
// matter if we send along a "null" value though.
$redirectUri = $this->request->get('redirect_uri');
$id = $this->request->getUser() ?: $this->request->get('client_id');
$secret = $this->request->getPassword() ?: $this->request->get('client_secret');
// If we have a client ID and secret we'll attempt to verify the client by
// grabbing its details from the storage adapter.
if ((!$strict or $strict and $id and $secret) and $client = $this->storage('client')->get($id, $secret, $redirectUri)) {
return $client;
}
throw new ClientException('client_authentication_failed', 'The client failed to authenticate.', 401);
}