FIWARE / tutorials.PEP-Proxy

:closed_book: FIWARE 404: Securing Microservices and IoT Devices with a PEP Proxy
https://fiware-pep-proxy.rtfd.io/
MIT License
7 stars 15 forks source link

Device group not found when accessing iot agent with an access token #10

Closed cxzero closed 3 years ago

cxzero commented 3 years ago

Hi,

In this step https://github.com/FIWARE/tutorials.PEP-Proxy#pep-proxy---accessing-iot-agent-with-an-access-token, I received this error:

curl -X POST \
  'http://localhost:7897/iot/d?k=4jggokgpepnvsb2uv4s40d59ov&i=motion001' \
  -H 'X-Auth-Token: ad50aa0f8d8c55530eb625768314a4a794f698e1' \
  -H 'Content-Type: text/plain' \
  -d 'c|1'

{"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group for fields: [\"resource\",\"apikey\"] and values: {\"resource\":\"/iot/d\",\"apikey\":\"4jggokgpepnvsb2uv4s40d59ov\"}"}

I investigated a bit more, an it is related to the specified apikey.

When listing all services I saw the apikey is different: "1068318794"

curl -iX GET   'http://localhost:4041/iot/services' \ 
 -H 'Content-Type: application/json'  
 -H 'fiware-service: openiot'  
 -H 'fiware-servicepath: /' | grep motion

{"count":4,"services":[{"commands":[],"lazy":[],"attributes":[{"object_id":"c","name":"count","type":"Integer"}],"_id":"6035612408f11a41cce55faa","resource":"/iot/d","apikey":"1068318794","service":"openiot","subservice":"/","timezone":"Europe/Berlin","__v":0,"static_attributes":[{"name":"category","type":"Text","value":["sensor"]},{"name":"controlledProperty","type":"Text","value":"motion"} ...

So running it with that apikey the result is ok.

curl -X POST \
  'http://localhost:7897/iot/d?k=1068318794&i=motion001' \
  -H 'X-Auth-Token: ad50aa0f8d8c55530eb625768314a4a794f698e1' \
  -H 'Content-Type: text/plain' \
  -d 'c|1'`

Just in case anyone is facing the same error or if there is a change to modify the database in order for the tutorial to run as expected.

Related to issue #5

Thanks in advance. Regards! Juan