3

I'm trying to accept a subscription confirmation from SNS using node.js.

I type my endpoint into the console and hit subscribe.

The documentation says

After you subscribe an HTTP/HTTPS endpoint, Amazon SNS sends a subscription confirmation message to the HTTP/HTTPS endpoint. This message contains a SubscribeURL value that you must visit to confirm the subscription (alternatively, you can use the Token value with the ConfirmSubscription).

So I'm doing this to preview the request so I can find the information I need.

if(req.headers['x-amz-sns-message-type'] === 'SubscriptionConfirmation'){
    console.log('subscription confirmation requested',req.headers);
    console.log('body:',req.body);
    var arn = req.headers['x-amz-sns-subscription-arn'];
    var topic = req.headers['x-amz-sns-topic-arn'];
    res.send(200);
}

I can't find SubscribeUrl or the Token in the headers or in the body.

The console line containing req.body just prints body: {} The console line containing req.headers doesn't contain SubscriptionUrl or Token

So where is it?

1 Answers1

2

It's in the raw data, that's where it is.

So I had to do this to get the data, then I could access it.

Community
  • 1
  • 1