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