I am trying to call a AWS REST API with Access Key and Secret Key. I need help for Authorization header generation. I had used HASH node but that is somehow not working.
Please let me know how to proceed on the same.
Hi Suchismita_Chakrabor - welcome to the Losant forums!
Can you please link to the documentation of the AWS API you’re trying to interact with? Just want to be sure before we suggest a solution.
Hi @Sebastian_Turner , the API url is https://ji935b0li6.execute-api.eu-west-1.amazonaws.com/v1/location/CNSJ.
I will try and get the API documentation by then.
Steps to Test API via Postman.pdf.zip (260.5 KB)
Hi @Sebastian_Turner , PFA documentation of API testing on Postman. Hope this helps.
Based on the information you provided, here is how I went about tracking this down …
- Create your request in Postman as you’ve done here. I’ve used different placeholder values to help keep track of what values are used where.
- In the “Code snippet” panel, view what the request looks like in cURL. A screenshot is attached.
This tells me that there are three headers that need to be set in the HTTP Node:
- x-api-key: This comes from your AWS account.
- X-Amz-Date: You can use a
{{formatDate}}
helper to get the date and build this. - Authorization: This one is more complicated and will take some work to generate. I found this document on everything that needs to go into the header and how to generate the signature.
Hopefully this points you in the right direction. I will add a feature request to add a method for generating that header in our workflow engine but I don’t have a timeline for when that will be complete.
Hi @Dylan_Schuster ,
Thanks for your reply.
The signature generation is the tricky which we tried with HASH node using
AWS documentation (Signature Calculations for the Authorization Header: Transferring Payload in a Single Chunk (AWS Signature Version 4) - Amazon Simple Storage Service) but it did not work.
Could you please help us with the node with which we may generate this HMAC Hexencode signature.
The Javascript code provided in AWS is supported for nodeJS (Examples of how to derive a signing key for Signature Version 4 - AWS General Reference) is not usable in the function node as well.
@Suchismita_Chakrabor thanks for the link to the Node example. I tried to implement this in a Losant workflow using the Hash Node but unfortunately it’s not something we can support at this time, as the Secret Template assumes the provided value is encoded in UTF-8 (though it’s actually hex-encoded).
If you are trying to do this from an Edge Workflow, you may be able to accomplish this in a Function Node by pulling in the crypto-js library.
I’m filing a feature request now to add that encoding option to the Hash Node’s secret; I’m told it’s an easy addition and I’m hoping to have it out in our next release but I can’t promise that. I will let you know when I have an update on this.
Thanks again for bringing your use case to our attention.
@Suchismita_Chakrabor just letting you know that we pushed an update out this afternoon that will allow for your use case, as we now allow for selecting an encoding type for all the Hash Node inputs and outputs. That should allow you to generate an AWS Signature Version 4 using the workflow engine.
Thanks again for bringing this up to us, and please let us know if you have any other questions!