How to do Custom Authentication in http header for MQTT-over-Websocket using C++ SDK?
Hi,
For "MQTT over WebSockets" found in https://docs.aws.amazon.com/iot/latest/developerguide/custom-auth.html, the credential can be passed "Through request headers or query parameters in the HTTP UPGRADE request to establish the WebSockets connection."
Does anyone know how to do this using the AWS IoT SDK C++? I understand that I can use Mqtt::OnWebSocketHandshakeIntercept() to embed authorisation into the HTTP header. However, it is unclear how it can be done since Http::HttpHeader basically only has name and value data members or is there another way to do it?
Any assistance is greatly appreciated,
Andi
Hi,
The AWS IoT Device SDK for C++ v2 supports the process for custom authorizers. You can modify the pubsub sample to test. Essentially set websocket to true, and then change the protocol as referenced here. This should then pass the additional HTTP Headers to the Custom Authorizer. The additional authParam
headers are processed here.
I haven't tested with C++, so please do respond if you are successful or not.
Edit: The above method would be for request headers used by POST or GET. Query headers could also be used by modifying the URI while still changing the protocol name.
Many thanks, Gavin! I have tried it and it is working well for me.
Relevant questions
How to do Custom Authentication in http header for MQTT-over-Websocket using C++ SDK?
Accepted Answerasked 4 months agoMQTT disconnects constantly
asked 5 years agoDifferences between C++ and C# AWS GameLift Server SDK
asked a year agoReturn a custom header from lambda authorizer in API-gateway (HTTP api)
asked a month agoCan I fully authenticate to AWS iOT through API Gateway HTTP using only header authentication methods?
asked 5 months agoConfigure MQTT over Websockets [ActiveMQ}
asked a year agoHow to use MQTT retained messages in custom Greengrass components?
Accepted Answerasked a month agoHow to create Signature V4 authentication header when uploading files as multipart/form-data in REST API of API Gateway?
asked 4 months agoAdding custom header to S3
asked 6 months agoHandel custom header in AWS API Gateway ?
Accepted Answerasked 12 days ago