Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws sigv4 not working with iot endpoint #5

Open
jayasai470 opened this issue Feb 11, 2019 · 2 comments
Open

aws sigv4 not working with iot endpoint #5

jayasai470 opened this issue Feb 11, 2019 · 2 comments

Comments

@jayasai470
Copy link

Hello,

i am having trouble with signature of aws canonical request, using your util
i am trying to make a post call for the iot endpoint
https://**-ats.iot.us-east-1.amazonaws.com/topics/test?qos=0
same req was working with postman client

   TreeMap<String, String> awsHeaders = new TreeMap<String, String>();
    awsHeaders.put("host", "***-ats.iot.us-east-1.amazonaws.com");
   TreeMap<String, String> awsQueryParam = new TreeMap<>();
    awsQueryParam.put("qos", "0");

    AWSV4Auth aWSV4Auth = new AWSV4Auth.Builder(accessKey, secretKey)
                            .regionName("us-east-1")
                            .serviceName("iotdata") // es - elastic search. use your service name
                            .httpMethodName("POST") //GET, PUT, POST, DELETE, etc...
                            .canonicalURI("topics/test") //end point
                            .queryParametes(awsQueryParam) //query parameters if any
                            .awsHeaders(awsHeaders) //aws header parameters
                            .payload(payload) // payload if any
                            .debug() // turn on the debug mode
                            .build();

but getting signature error

Client error <403 FORBIDDEN Forbidden,{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.","traceId":"80e40ad7-9db1-7a60-809a-889c9fecb852"},[date:"Mon, 11 Feb 2019 20:57:32 GMT", x-amzn-ErrorType:"ForbiddenException:", x-amzn-RequestId:"80e40ad7-9db1-7a60-809a-889c9fecb852", connection:"keep-alive", content-type:"application/json", content-length:"241"]>

let me know if i am doing anything wrong

Thank you,

@jayasai470
Copy link
Author

figured it out, needed to stringify my payload properly
Thanks for the util

@Dagudelot
Copy link

He jayasai470. Can you please tell me how you solved this issue? What is the propr way to stringify the payload?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants