From 801895e2d23739e214a64fe01892db028958d70d Mon Sep 17 00:00:00 2001 From: Boris Krivonog Date: Tue, 16 Aug 2022 22:11:49 +0200 Subject: [PATCH] Refresh token if expired (#13274) Signed-off-by: Boris Krivonog --- .../binding/automower/internal/bridge/AutomowerBridge.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/bridge/AutomowerBridge.java b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/bridge/AutomowerBridge.java index 4d086129f..1755a5ce0 100644 --- a/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/bridge/AutomowerBridge.java +++ b/bundles/org.openhab.binding.automower/src/main/java/org/openhab/binding/automower/internal/bridge/AutomowerBridge.java @@ -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;