An electronic device and a method for controlling the electronic device are provided. The electronic device includes a sensor, a
communication unit, memory, including one or more storage media, storing instructions, and at least one processor communicatively coupled to the sensor, the
communication unit, and the memory, wherein the instructions, when executed by the at least one processor individually or collectively, cause the electronic apparatus to, identify whether a first type of sensor is included in the sensor when a request for access to a first type of sensor is received from an external device through the
communication unit, perform
authentication for allowing the external device to access the first type of sensor when the first type of sensor is identified to be included in the sensor, block another application remaining after excluding at least one application related to access to the first type of sensor by the external device from among
multiple applications of the electronic device and other devices remaining after excluding the external device from accessing the first type of sensor, establish a security channel for communication with the external device by using
encryption information, and when
sensing data is obtained through the first type of sensor, control the communication unit to transmit information on the
sensing data to the external device through the established security channel.