aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-notifications/src/main/java')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/MPNSClient.java13
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 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<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();