0

I am using the following commands to create a tenant in Eclipse Hono

$ curl -X POST -i -H 'Content-Type: application/json' -d '{"tenant-id": "testenant1"}' 
http://localhost:28080/tenant
HTTP/1.1 201 Created
location: /tenant/testenant1
content-length: 0

Registering a device in the tenant using the below command

curl -X POST -i -H 'Content-Type: application/json' -d '{"device-id": "1"}' 
http://localhost:28080/registration/testenant1
HTTP/1.1 201 Created
location: /registration/testenant1/1
content-length: 0

Authenticating the registered device using the below command

$ curl -i -X POST -H 'Content-Type: application/json' --data-binary '{
     "device-id": "1",
    "type": "hashed-password",
     "auth-id": "newAuth1",
     "secrets": [{
           "pwd-plain": "mylittle"
     }]
     }' http://localhost:28080/credentials/testenant1
HTTP/1.1 201 Created
location: /credentials/testenant1/newAuth1/hashed-password
content-length: 0

When I try to send data to this registered and Authenticated device using the below command.

curl -X POST -i -u newAuth1@testenant1:mylittle -H 'Content-Type: application/json' -d '{"temp": 23.07, "hum": 45.85}'  http://localhost:8080/telemetry

HTTP/1.1 401 Unauthorized content-length: 0

I will be getting 401 Unauthorized error (I am expecting 503 - Service Unavailable error).

Note: I was using the similar approach before and it was working perfectly fine. I am not sure if I am missing something.

Yannic Bürgmann
  • 6,301
  • 5
  • 43
  • 77

1 Answers1

0

You are using wrong credentials when POSTing the data. The username always consists of the auth-id and the tenant-id separated by @.

You need to use:

curl -X POST -i -u newAuth1@testenant1:mylittle -H 'Content-Type: application/json' -d '{"temp": 23.07, "hum": 45.85}'  http://localhost:8080/telemetry

That said, based on the URIs you are using for registering the tenant and device, you seem to be using quite an old version of Hono. Please consider upgrading to the latest version (1.1.1) in order to take advantage of recent development/bug fixing ...

Kai Hudalla
  • 826
  • 1
  • 5
  • 7