Skip to content

Commit aa0e92f

Browse files
committed
chore(log): Log additional information in case of a failed token request to improve observability
1 parent 7862686 commit aa0e92f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

camunda-sdk-java/java-common/src/main/java/io/camunda/common/auth/SaaSAuthentication.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,25 @@ private TokenResponse retrieveToken(Product product, JwtCredential jwtCredential
3131
HttpPost request = buildRequest(jwtCredential);
3232
return client.execute(
3333
request,
34-
response ->
35-
jsonMapper.fromJson(EntityUtils.toString(response.getEntity()), TokenResponse.class));
34+
response -> {
35+
try {
36+
return jsonMapper.fromJson(
37+
EntityUtils.toString(response.getEntity()), TokenResponse.class);
38+
} catch (Exception e) {
39+
var errorMessage =
40+
"""
41+
Token retrieval failed from: {}
42+
Response code: {}
43+
Audience: {}
44+
""";
45+
LOG.error(
46+
errorMessage,
47+
jwtCredential.getAuthUrl(),
48+
response.getCode(),
49+
jwtCredential.getAudience());
50+
throw e;
51+
}
52+
});
3653
} catch (Exception e) {
3754
LOG.error("Authenticating for " + product + " failed due to " + e);
3855
throw new RuntimeException("Unable to authenticate", e);

0 commit comments

Comments
 (0)