From 909c5a35daa2be01fa7c2829f2b7e990b28e8bad Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 18 Oct 2017 02:35:43 +0300 Subject: notifications: fix mpns --- .../src/main/java/com/juick/components/MPNSClient.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'juick-notifications') diff --git a/juick-notifications/src/main/java/com/juick/components/MPNSClient.java b/juick-notifications/src/main/java/com/juick/components/MPNSClient.java index 0cbbd1e4..f44db194 100644 --- a/juick-notifications/src/main/java/com/juick/components/MPNSClient.java +++ b/juick-notifications/src/main/java/com/juick/components/MPNSClient.java @@ -8,6 +8,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.*; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -36,13 +38,14 @@ public class MPNSClient { @PostConstruct public void authenticate() throws IOException { String url = "https://login.live.com/accesstoken.srf"; + MultiValueMap form = new LinkedMultiValueMap<>(); + form.add("grant_type", "client_credentials"); + form.add("client_id", applicationSip); + form.add("client_secret", applicationSecret); + form.add("scope", "notify.windows.com"); HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add("grant_type", "client_credentials"); - httpHeaders.add("client_id", applicationSip); - httpHeaders.add("client_secret", applicationSecret); - httpHeaders.add("scope", "notify.windows.com"); httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - HttpEntity entity = new HttpEntity<>(httpHeaders); + HttpEntity> entity = new HttpEntity<>(form, httpHeaders); ResponseEntity response = restService.getRest().exchange(url, HttpMethod.POST, entity, String.class); String responseBody = response.getBody(); HttpStatus statusCode = response.getStatusCode(); -- cgit v1.2.3