Three ways to sign URLs for Amazon Web Services

This post is more than 2 years old.

Last week I was doing some experiments with the Amazon web service API. For the most part it is pretty self explanatory. The part that was difficult was figuring out how to construct the URL so it can authenticate with Amazon. In researching this issue I found three different solutions. I'm writing them down here mainly for my own needs so I can find it later.

Flex/Flash/AIR apps: You can use the ActionScript code here: Signing Amazon Web Service Requests in ActionScript

JavaScript apps: Technically this isn't a library, but Amazon has an online URL signer here: Signed Requests Helper. You can view source to see the JavaScript used. I'm not sure you would ever use this in production as it implies putting your access keys in the view source, but it's another option.

ColdFusion apps: I used the Amazon Product Advertising API Signature Generator from Tim Dawe and it worked very easily. You provide the "base" URL and the CFC will handle returning the URL with all the extra crap at the end. So for example:

<cfset accesskey = "key here"> <cfset secretkey = "secret key here">

<cfset theurl = ""> <cfset theurl = signRequest(theurl, secretkey)> <cfhttp url="#theurl#">

In case you are curious, that code above did an image search on the Depeche Mode Violator album which returned the CD cover. Pretty cool (and yes, it's what I was originally trying to do).

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Gregg posted on 8/17/2014 at 8:58 PM


I know this post is really old, but I'm hoping you can help.

I used the Amazon Product Advertising API Signature Generator and it works when I take the signed url it creates and just open that url in a browser. However, when I try to use that url in cfhttp, I get SignatureDoesNotMatch.

I actually had it working in an early version of CF10, but I have to use CF11.

Any help would be greatly appreciated.


Comment 2 by Gregg posted on 8/17/2014 at 10:46 PM

I got my answer here! Thanks ;)

Comment 3 by Raymond Camden posted on 8/18/2014 at 3:07 PM

Woot, glad you got it, and thanks for posting back what worked.