Log response body if one exists

If the OpenID Connect server returns an invalid client error, you can't find that in the logging (because the real error is only visible in the response body).

Logged:
`HTTP Status 401 - Authentication Failed: Unable to obtain Access Token: 401 Unauthorized`

Non logged:
`{"error_description":"Client authentication failed: Invalid authentication","error":"invalid_client"}`
pull/1049/head
jevanlingen 2016-03-29 10:44:28 +02:00
parent 37bead1404
commit f1c4b79d4d
1 changed files with 4 additions and 0 deletions

View File

@ -416,6 +416,10 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
logger.error("Token Endpoint error response: " + e.getMessage()); logger.error("Token Endpoint error response: " + e.getMessage());
if (e instanceof HttpClientErrorException) {
logger.debug("Token Endpoint message body: " + ((HttpClientErrorException) e).getResponseBodyAsString());
}
throw new AuthenticationServiceException("Unable to obtain Access Token: " + e.getMessage()); throw new AuthenticationServiceException("Unable to obtain Access Token: " + e.getMessage());
} }