Refresh token if expired (#13274)
Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>
This commit is contained in:
parent
0a79b8574c
commit
801895e2d2
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue