diff --git a/camunda-sdk-java/java-common/src/main/java/io/camunda/common/auth/SaaSAuthentication.java b/camunda-sdk-java/java-common/src/main/java/io/camunda/common/auth/SaaSAuthentication.java index 063f34032..86f728903 100644 --- a/camunda-sdk-java/java-common/src/main/java/io/camunda/common/auth/SaaSAuthentication.java +++ b/camunda-sdk-java/java-common/src/main/java/io/camunda/common/auth/SaaSAuthentication.java @@ -31,8 +31,20 @@ private TokenResponse retrieveToken(Product product, JwtCredential jwtCredential HttpPost request = buildRequest(jwtCredential); return client.execute( request, - response -> - jsonMapper.fromJson(EntityUtils.toString(response.getEntity()), TokenResponse.class)); + response -> { + try { + return jsonMapper.fromJson( + EntityUtils.toString(response.getEntity()), TokenResponse.class); + } catch (Exception e) { + String errorMessage = "Token retrieval failed from: {}\n" + "Response code: {}\n" + "Audience: {}"; + LOG.error( + errorMessage, + jwtCredential.getAuthUrl(), + response.getCode(), + jwtCredential.getAudience()); + throw e; + } + }); } catch (Exception e) { LOG.error("Authenticating for " + product + " failed due to " + e); throw new RuntimeException("Unable to authenticate", e);