Amazon SNS:如何获取令牌以确认订阅

nav*_*yad 3 boto amazon-sns python-2.7

以下创建一个等待确认的订阅。

aws_client.subscribe(TopicArn=topic_arn, Protocol=protocol, Endpoint=endpoint)
Run Code Online (Sandbox Code Playgroud)

对此的回应是这样的:

{'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'}
Run Code Online (Sandbox Code Playgroud)

上面的响应没有发送任何令牌。如何获得这可以传递给confirm_subscription如规定的令牌这里

D.T*_*ate 7

看来,该令牌在subscribe命令本身的响应中是不可用的。相反,如Boto 3 文档中所述,令牌是

“...由较早的订阅操作发送到端点。” (强调我的)

AWS CLI命令参考指出同样的事情,但多一点点清晰也许:

“在订阅操作期间发送到端点的短期令牌。” (强调我的)

换句话说,对于电子邮件端点,令牌位于电子邮件本身中。如果您查看“确认订阅”链接的 URL,您就可以看到它。

例如,它看起来像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

在此示例中,您可以看到 Token 为abc123