Refresh token if expired (#13274)

Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>
This commit is contained in:
Boris Krivonog 2022-08-16 22:11:49 +02:00 committed by GitHub
parent 0a79b8574c
commit 801895e2d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -13,6 +13,7 @@
package org.openhab.binding.automower.internal.bridge;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jdt.annotation.NonNullByDefault;
@ -54,7 +55,7 @@ public class AutomowerBridge {
private AccessTokenResponse authenticate() throws AutomowerCommunicationException {
try {
AccessTokenResponse result = authService.getAccessTokenResponse();
if (result == null) {
if (result == null || result.isExpired(LocalDateTime.now(), 120)) {
result = authService.getAccessTokenByClientCredentials(null);
}
return result;