0
votes

I am trying to implement AWS Push notifications in my mobile application using GCM. As part of registering the GCM token with AWS, I am trying to create the endpoint with AWS using API [CreatePlatformEndpoint] http://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html. As part of calculating the Signature, i am following below website

http://docs.aws.amazon.com/general/latest/gr/signature-version-2.html#API_SignatureSampleCode

I have used below code for creating Signature Version for AWS

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/AuthJavaSampleSig2.html

I am able to create below URL

http://sns.us-west-2.amazonaws.com/?AWSAccessKeyId=XXXXXXXXXXXXX&Action=CreatePlatformEndpoint&CustomUserData=Rajan&PlatformApplicationArn=arn%3Aaws%3Asns%3Aus-west-2%3A798120381702%3Aapp%2FGCM%2FAndroidMobilePushApp&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-07-04T18%3A35%3A27Z&Token=APA91bHKDGeNTMfCCdy1wetqxAu2yePhrkDb3KZIdYxJD1VoBnN4yh0CCw_WiAUd-MKM4eqjHixIswvMNMAa0FFByTeG0GcitHuqaP6IIMDiSvcbl-jV8jVoAjPufbWUEtDTA-0E8SmTacaLeBrZ-LCTzk65UOzsiunE75M-UalPro6p4bcSpj4&Version=2010-03-31&Signature=zPM6rDK9BhsaMLD5csiAqO6j30tVJ76Yy6FMcOzc4B4%3D%0A

Here is the response i got.

<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
<Error>
<Type>Sender</Type>
<Code>SignatureDoesNotMatch</Code>
<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.
</Message>
</Error>
<RequestId>f00722e6-d9cb-5747-ab51-6ed62f2d6b75</RequestId>
</ErrorResponse>

Can someone guide what is the error?

2

2 Answers

0
votes

I think you should't have a %0A at the end of your signature. Don't know where you get it from.

0
votes

Finally after lot of debugging, i could resolve the issue and the issue was very simple :( ...

It was not a POST request. It had to be a GET request only. I don't know why the documentation shows it to be a POST request.