diff options
author | Vitaly Takmazov | 2017-10-18 02:35:43 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-18 02:35:43 +0300 |
commit | 909c5a35daa2be01fa7c2829f2b7e990b28e8bad (patch) | |
tree | 64478d76b15491a2adae45cd26568193cbe90a7f /juick-notifications/src/main | |
parent | 14b8e6b8fffdd6dac1467c1aed40c2f029564bf1 (diff) |
notifications: fix mpns
Diffstat (limited to 'juick-notifications/src/main')
-rw-r--r-- | juick-notifications/src/main/java/com/juick/components/MPNSClient.java | 13 |
1 files changed, 8 insertions, 5 deletions
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 0cbbd1e4a..f44db1949 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<String, String> 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<String> entity = new HttpEntity<>(httpHeaders); + HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(form, httpHeaders); ResponseEntity<String> response = restService.getRest().exchange(url, HttpMethod.POST, entity, String.class); String responseBody = response.getBody(); HttpStatus statusCode = response.getStatusCode(); |