public function authorize()
    {
        $response = new Response();

        /** @var Response $response */
        $response = $this->oauthServer->handleAuthorizeRequest(Request::createFromGlobals(), $response, true);
        if (!$response->getParameters()) {
            $code = substr(
                $response->getHttpHeader('Location'),
                strpos($response->getHttpHeader('Location'), 'code=') + 5,
                40
            );
            return $this->response->sendSuccess(['code' => $code]);
        } else {
            return $this->response->sendError(
                ResponseCodes::AUTH_ERROR,
                $response->getStatusCode(),
                $response->getParameter('error_description')
            );
        }
    }