session = $session; } /** * @param Request $request * * @return JSON_Response * * @throws API_Exception */ public function authenticate( Request $request ) { $socket_id = $request->post( 'socket_id' ); $pusher_session_id = $this->session->get( Authenticate_Filter::PUSHER_SESSION_ID_KEY ); try { $integration_id = $this->storage->get_oauth()->get_integration_id(); $result = $this->api_wrapper->authenticate_channel( $integration_id, $pusher_session_id, $socket_id ); $status_code = 200; $response = $result; } catch ( TokenNotFoundException $e ) { $status_code = 404; $response = array( 'error' => 'OAuth token not found.', ); } catch ( ValidationException $e ) { $status_code = 400; $response = array( 'error' => 'Validation error', ); } return $this->json( $response, $status_code ); } }