OlatLmsRestTemplate: also refresh auth token when receiving 403 FORBIDDEN
This commit is contained in:
parent
855890b617
commit
ef407eab8d
1 changed files with 2 additions and 1 deletions
|
@ -55,7 +55,8 @@ public class OlatLmsRestTemplate extends RestTemplate {
|
||||||
ClientHttpResponse response = execution.execute(request, body);
|
ClientHttpResponse response = execution.execute(request, body);
|
||||||
log.debug("OLAT [regular API call] {} Headers: {}", response.getStatusCode(), response.getHeaders());
|
log.debug("OLAT [regular API call] {} Headers: {}", response.getStatusCode(), response.getHeaders());
|
||||||
// If we get a 401, re-authenticate and try once more
|
// 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();
|
authenticate();
|
||||||
request.getHeaders().set("X-OLAT-TOKEN", OlatLmsRestTemplate.this.token);
|
request.getHeaders().set("X-OLAT-TOKEN", OlatLmsRestTemplate.this.token);
|
||||||
response = execution.execute(request, body);
|
response = execution.execute(request, body);
|
||||||
|
|
Loading…
Reference in a new issue