public function __construct(ClientCredentialsInterface $storage, array $config = array())
 {
     /**
      * The client credentials grant type MUST only be used by confidential clients
      *
      * @see http://tools.ietf.org/html/rfc6749#section-4.4
      */
     $config['allow_public_clients'] = false;
     parent::__construct($storage, $config);
 }
 public function validateRequest(\OAuth2\RequestInterface $request, \OAuth2\ResponseInterface $response)
 {
     if (!$request->request('authkey') || !$request->request('username')) {
         $response->setError(400, 'invalid_request', 'Missing parameters: "authkey" and "username" required');
         return null;
     }
     if (!$this->userStorage->findIdentityByAccessToken($request->request('authkey'))) {
         $response->setError(401, 'invalid_grant', 'Invalid user authkey');
         return null;
     }
     $userInfo = $this->userStorage->getUserDetails($request->request('username'));
     if (empty($userInfo)) {
         $response->setError(400, 'invalid_grant', 'Unable to retrieve user information');
         return null;
     }
     if (!isset($userInfo['user_id'])) {
         throw new \LogicException('you must set the user_id on the array returned by getUserDetails');
     }
     $this->userInfo = $userInfo;
     return parent::validateRequest($request, $response);
 }
 public function __construct(ClientCredentialsInterface $storage, array $config = array())
 {
     $config['allow_public_clients'] = false;
     parent::__construct($storage, $config);
 }