Amazon SNS: how to get token for confirm subscription

那年仲夏 提交于 2020-01-15 01:50:12

问题


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


回答1:


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&Endpoint=address@email.com

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



来源:https://stackoverflow.com/questions/46728286/amazon-sns-how-to-get-token-for-confirm-subscription

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!