"Host requires authentication" Error with Ingestion SDK

I’m testing around with the ingestion sdk and I keep getting a return response as seen in the title. I’m using the examples in the docs for signing and creating a basic file called test/encoded.cbor.

I’m assuming I’m just overlooking something in terms of this hmac key or something. I’m using the same API KEY I would use when connecting using the remote mgmt protocol.

Could someone give me a few pointers or places to look in order to resolve this “Host requires authentication,” error? I’m new to all of this cryptographic/context/singing stuff and I’m still trying to wrap my head around all of this.

Also note, I do have all of the necessary library and SDK’s included such as MBEDTLS and QCbor, etc.

Update:

It seems as though the signature being written to the encoded.cbor file is still the uninitialized 64 times 0.

I must be missing where to change this, I assumed from the example that the updating of the signature was done through the functionality already present.

I’ve found

int ctx_err = ctx->signature_ctx->init(ctx->signature_ctx);

In the source, so I assume I’m missing a step. Will keep digging.

@DoitfortheLulz When do you get this message? When sending data to ingestion or? If the HMAC key misses I’d expect a different error (and it will just pass through anyway, just marked as not signed in the studio).

So, initially, I was getting Internal server errors and then eventually a:

  • 400 - Invalid message, e.g. fields are missing, or are invalid. See body for more information.

But these were resolved, just user errors when formatting my headers, etc.

I get this message after the message has been sent. Its the returned response from the API after POSTING

This will probably be a stupid question, but do I pass in any hmac key, something I create myself? Or is there some functionality I’m overlooking to generate one?

@janjongboom Upon further inspection it seems as though its returning 401 error, indicating either an invalid API_KEY or possibly the header data is messed up on my end. I’m not sure why though because I’m using the same API_key to connect to the remote mgmt service as well with no issue at all.

@DoitfortheLulz Can you send me your full request (binary payload + all the headers you send) to jan@edgeimpulse.com ?

@janjongboom As of about 20 minutes ago, I’ve fixed this issue.

The headers in my request were incorrectly formatted. Just spent to much time working on my project by the time I got to this segment, so I was already a little fried.

I’m successfully sending data to the ingestion service! Such a good feeling! Sorry for not responding sooner!

No problem! Thanks for reporting back!

Quick question, @janjongboom

This line in the docs here states to replace the values field with a string containing the “Ref-Binar…”

How is this achieved? Because the three functions such as:

take in ints/floats etc. Do I need to manually manipulate the generated cbor file to replace the encoded data with value: [ “Ref-Binary-i16” ]?

Yeah, e.g. this is how we do it: https://github.com/edgeimpulse/firmware-nrf52840-5340-dk/blob/5d5c2dc8650622f0c142e0b70f050d4aff538129/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/sensors/ei_microphone.cpp#L207

It’s not the most pretty part of the code :wink: If you’re on Linux just stick it in the values array instead.

Yeah it always hurts, but sometimes you have to sacrifice eloquence for a solution! I’ll dig into this. Thanks for the fast response.

If I add the axis unit as “wave,” do I still need to strip the wav header from the file before appending the file?

Yes, set the name of the axis to audio and then just write raw PCM values to the values array (if you have a PCM16 WAV file just skip the first 44 bytes or so, typical header size, and write the rest).

And when writing the raw PCM data that I have, I should still be utilizing the sensor_aq_add_data/batch functions, correct?

Sorry for the noob questions, I’m still trying to learn.

That indeed works if you don’t use the ‘Ref-BINARY-i16’ flow. If you do, just dump the i16 array after the payload.

Okay I’ll give it a shot.

@janjongboom

It seems as though the values array is not being updated. Every time I parse the CBOR file, its empty.

I’m assuming from:

That the returned size or possible the buffer ptr is not in the correct position. It’s actually a bit difficult to debug this on my end because I’m running on an Android device.

But I’ll keep digging.

@janjongboom Have you encountered this issue before?

Does this reference the binary data that I’m appending or is it saying there is an issue with:

"values" : [ "Ref-Binary-i16" ]

For reference, this is the message, minus the appended raw audio data.

@janjongboom

So, I finally got data posting to the ingestion service. But, I’m attempting to use the Binary Payload upload methods as mentioned in the docs. But, I keep getting the previously mentioned:

But, I went ahead and copied the example byte array from the docs into CBOR playground and my message seems to be formatted exactly the same, what would cause this to error out?

Here is my CBOR:

@DoitfortheLulz values should be a string, not an array of strings for binary payloads.

So:

    "values": "Ref-BINARY-i16"

!