navyad
navyad

Reputation: 3860

Amazon SNS: how to get token for confirm subscription

Following creates a subscription waiting to be confirmed.

aws_client.subscribe(TopicArn=topic_arn, Protocol=protocol, Endpoint=endpoint)

response of this is something like:

{'ResponseMetadata': {'HTTPHeaders': {'content-length': '298',
   'content-type': 'text/xml',
   'date': 'Fri, 13 Oct 2017 10:15:47 GMT',
   'x-amzn-requestid': '7a0a40fb-ab72-5584-94f0-12a13fe11das'},
  'HTTPStatusCode': 200,
  'RequestId': '7a0a40fb-ab72-5584-94f0-12a13fe11das',
  'RetryAttempts': 0},
 u'SubscriptionArn': 'pending confirmation'}

above response did not send any token. How to get the token which can be passed to confirm_subscription as stated here

Upvotes: 5

Views: 6109

Answers (1)

D.Tate
D.Tate

Reputation: 2309

It seems, the Token is not available from inside the response of the subscribe command itself. Rather, as mentioned in the Boto 3 documentation, the token is

"...sent to the endpoint by an earlier Subscribe action." (emphasis mine)

The AWS CLI Command Reference states the same thing, but a little bit more clearly perhaps:

"Short-lived token sent to an endpoint during the subscribe action." (emphasis mine)

In other words, for an Email Endpoint, the Token is in the email itself. You can see it if you look at the URL for the "Confirm subscription" Link.

For example, it will look something like https://sns.us-east-1.amazonaws.com/confirmation.html?TopicArn=arn:aws:sns:us-east-1:123456789:my-aws-topic&Token=abc123&[email protected]

Here in this example, you can see the Token would be abc123.

Upvotes: 6

Related Questions