Skip to content

Commit

Permalink
use explicit Accept header to ensure xml response (#4322)
Browse files Browse the repository at this point in the history
* use explicit Accept header to ensure xml response

fixes #4321

* copyright update
  • Loading branch information
brianhatchl authored Oct 20, 2020
1 parent 9dd6f27 commit e5f751f
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2018 DigitalGlobe (http://www.digitalglobe.com/)
* @copyright Copyright (C) 2018, 2020 DigitalGlobe (http://www.digitalglobe.com/)
*/
package hoot.services.controllers.auth;

Expand All @@ -41,6 +41,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth.consumer.OAuthConsumerSupport;
import org.springframework.security.oauth.consumer.OAuthConsumerToken;
import org.springframework.security.oauth.consumer.OAuthRequestFailedException;
Expand Down Expand Up @@ -102,8 +106,13 @@ public Response verify(@QueryParam("oauth_token") String oauth_token, @QueryPara
OAuthSecurityContext context = OAuthSecurityContextHolder.getContext();
context.getAccessTokens().put(r.getId(), accessToken);

String response = oauthRestTemplate
.getForObject(HootProperties.OAUTH_PROVIDERURL + HootProperties.OAUTH_PATHS_USER, String.class);
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", "application/xml");
HttpEntity<String> entity = new HttpEntity<>(headers);

ResponseEntity<String> responseEntity = oauthRestTemplate.exchange(
HootProperties.OAUTH_PROVIDERURL + HootProperties.OAUTH_PATHS_USER, HttpMethod.GET, entity, String.class);
String response = responseEntity.getBody();
Users user;
try {
user = userManager.upsert(response, accessToken, sess.getId());
Expand Down

0 comments on commit e5f751f

Please sign in to comment.