PDA

View Full Version : Amazon wont Accept AWSAccessKeyID?!?




Cdub16
Sep 26, 2009, 10:06 PM
hey i am on chapter 28 of Aaaron Hillegass' book on cocoa programming. i set up an account on aws.amazon.com with an AWSAccesKeyID but when i use it in my program with this:
NSString *urlString = [NSString stringWithFormat:
@"http://ecs.amazonaws.com/onca/xml"
@"Service=AWSECommerceService&"
@"AWSAccessKeyID=%@&"
@"Operation=ItemSearch&"
@"SearchIndex=Books&"
@"Keywords=%@&"
@"Version=2007-07-16",
AWS_ID, searchString];
(with the AWS_ID being the id i just set up.)

the xml i recieve still tells me it has a problem with the AWSAccesKeyID

this is the message i get in the console when i print out the xml:
<?xml version="1.0" standalone="yes"?><ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2007-07-16/"><Error><Code>MissingClientTokenId</Code><Message>Request must contain AWSAccessKeyId or X.509 certificate.</Message></Error><RequestID>a2cbd752-af96-48f5-baa2-c4f51d3ad4c8</RequestID></ItemSearchErrorResponse>

what am i doing wrong??



Cdub16
Sep 26, 2009, 10:07 PM
I am trying to search names of books on amazons website.

Matthew Yohe
Sep 26, 2009, 10:31 PM
I am trying to search names of books on amazons website.

What does your definition of AWS_ID look like? (just xxx out some or all of the ID numbers)

Matthew Yohe
Sep 26, 2009, 10:36 PM
Oh... Amazon requires signed requests now, that example isn't going to work.

Here's how to sign it:
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?rest-signature.html

Cdub16
Sep 26, 2009, 11:06 PM
ya thanks ive been looking into that. got pretty confusing but i got it thanks for the reply

rafer11
Apr 12, 2011, 10:21 PM
I'm having this exact same issue and I can't seem to solve it through the link.

I also have this code [from Hillegass's book]


#define AWS_ID @"<ID is in here>"

...
//Create the URL (long string broken into several lines is OK)
NSString *urlString = [NSString stringWithFormat:
@"http://ecs.amazonaws.com/onca/xml?"
@"Service=AWSECommerceService&"
@"AWSAccessKeyID=%@&"
@"Operation=ItemSearch&"
@"SearchIndex=Books&"
@"Keywords=%@&"
@"Version=2007-07-16",
AWS_ID, searchString];



I get the same error as above.

<?xml version="1.0" standalone="yes"?><ItemSearchErrorResponse xmlns="http://ecs.amazonaws.com/doc/2007-07-16/"><Error><Code>MissingClientTokenId</Code><Message>Request must contain AWSAccessKeyId or X.509 certificate.</Message></Error><RequestID>33815e66-73eb-4152-a1e6-98db44c4317f</RequestID></ItemSearchErrorResponse>

If I add the 'signature' stuff that the link requires for 'ItemSearch', I end up getting the same error.


@"Signature=TuM6E5L9u%2FuNqOX09ET03BXVmHLVFfJIna5cxXuHxiU%3D&"


Likely because I just copied the signature value, and timestamp they had in the example.

What do I need to do to get a proper signature, or to make this work?

McGordon
Apr 13, 2011, 10:56 AM
Amazon changed their web service so that won't work.

You can get a replacement for that chapter here:

http://bignerdranch.com/book/cocoa®_programming_for_mac®_os_x_3rd_edition