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); }