Merge pull request #53 from sealexan/dev-1.3

OlatLmsRestTemplate: also refresh auth token when receiving 403 FORBIDDEN
This commit is contained in:
Andreas Hefti 2022-05-12 19:51:43 +02:00 committed by GitHub
commit 289078f4fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);