From ef407eab8d1e52c9d62090c18b9eccddbece106c Mon Sep 17 00:00:00 2001 From: Carol Alexandru Date: Thu, 12 May 2022 14:56:40 +0200 Subject: [PATCH] OlatLmsRestTemplate: also refresh auth token when receiving 403 FORBIDDEN --- .../servicelayer/lms/impl/olat/OlatLmsRestTemplate.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java index bc026a1f..3f67d36e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/olat/OlatLmsRestTemplate.java @@ -55,7 +55,8 @@ public class OlatLmsRestTemplate extends RestTemplate { ClientHttpResponse response = execution.execute(request, body); log.debug("OLAT [regular API call] {} Headers: {}", response.getStatusCode(), response.getHeaders()); // If we get a 401, re-authenticate and try once more - if (response.getStatusCode() == HttpStatus.UNAUTHORIZED) { + if (response.getStatusCode() == HttpStatus.UNAUTHORIZED || + response.getStatusCode() == HttpStatus.FORBIDDEN) { authenticate(); request.getHeaders().set("X-OLAT-TOKEN", OlatLmsRestTemplate.this.token); response = execution.execute(request, body);