Seems like this line:
ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, HttpEntity.EMPTY, Void.class, parameters);
Doesn't work when called from the redirection code:
return getAuthorizationCode(location.toString(), Maps.newLinkedHashMap(), false);
When the password contain special characters, because it will double encode it