String credentials = clientId + ":" + clientSecret; String authHeader = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes()); System.out.println("authHeader==>" + authHeader); // Create request URL StringBuilder requestBuilder = new StringBuilder() .append("https://authz.constantcontact.com/oauth2/default/v1/token").append("?code=") .append(authCode).append("&redirect_uri=").append(redirectUri) .append("&grant_type=authorization_code"); System.out.println("url==>" + requestBuilder.toString()); MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>(); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.set("Accept","application/json"); headers.set("Authorization", authHeader); HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(requestBody, headers); ResponseEntity<String> response = restTemplate.exchange(requestBuilder.toString(), HttpMethod.POST, entity, String.class); System.out.println("response==>"+response);
... View more