java – How to use AWS IoT MQTT with AWS Congnito User Pool
I might be very dumb but for few days I’, fighting to find out a solution how to connect to AWS IoT MQTT having auth flow based on CognitoIdentityProviderClient.
My setup look like this:
- I Have user pool “some-user-pool”
- I Have a user in user pool “some-user-in-user-pool”
- My user pool is attached to IoT Policy “some-iot-policy”
What next? meaning I know I can connect to mqtt by certificate attached to policy but I want to use this user.
So I’m on a step where I have final RespondToAuthChallengeResponse after auth flow; everything went well but I cannot figure out what now? What I can do to setup AwsIotMqtt5ClientBuilder to use user pool.
In code it’s like
RespondToAuthChallengeResponse response = cognitoIdentityProviderClient.respondToAuthChallenge(request)
//After this I have accessToken and idToken
AwsIotMqtt5ClientBuilder builder = AwsIotMqtt5ClientBuilder.newMqttBuilder(hostname)
//here I'm lost how I can setup mqtt to use the response
Read more here: Source link
