我正在与AWS SNS一起确认订阅端点,并与请求一起获取了带有令牌的整个数据,但是当我传递相同的令牌以确认用于订阅的https端点时,那么我将获得无效的令牌...
我的代码:
@Value("${accessKey}")
private String accessKey;
@Value("${secretKey}")
private String secretKey;
@Value("${topicArn}")
private String topicArn;
@NotificationSubscriptionMapping
public void handleSubscriptionMessage(HttpServletRequest request) throws IOException {
/* String token = "";
String reqData = "";
logger.info("Received Subscription Message. Confirming...");
AmazonSNSClient client = getCredentials();
try {
reqData = IOUtils.toString(request.getInputStream());
logger.info("reqData : " + reqData);
JsonObject jsonData = new Gson().fromJson(reqData, JsonObject.class);
logger.info("jsonData : " + jsonData);
token = jsonData.get("Token").toString();
logger.info("Token : " + token);
} catch (IOException e) {
e.printStackTrace();
}
ConfirmSubscriptionRequest confirmSubscriptionRequest = new ConfirmSubscriptionRequest().withTopicArn(topicArn)
.withToken(token);
ConfirmSubscriptionResult confirmSubscriptionResult = client.confirmSubscription(confirmSubscriptionRequest);
}
private AmazonSNSClient getCredentials() {
AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
final AmazonSNSClient client = new AmazonSNSClient(awsCredentials);
client.setRegion(Region.getRegion(Regions.US_EAST_1));
return client;
}