aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Model
diff options
context:
space:
mode:
Diffstat (limited to 'Digitigrade/Model')
-rw-r--r--Digitigrade/Model/Instance.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/Digitigrade/Model/Instance.php b/Digitigrade/Model/Instance.php
index e4b1ef1..7176fcd 100644
--- a/Digitigrade/Model/Instance.php
+++ b/Digitigrade/Model/Instance.php
@@ -97,7 +97,9 @@ class Instance extends FetchableModel {
$this->auth->outboundToken = $data->token;
$this->save();
- (new RefreshOutboundAuthToken($this->domain, new \DateTimeImmutable($data->expires)))->submit();
+ // try to refresh it 1 hour before it expires, to leave some leeway
+ $refreshAt = (new \DateTimeImmutable($data->expires))->sub(new \DateInterval('PT1H'));
+ (new RefreshOutboundAuthToken($this->domain, $refreshAt))->submit();
}
public function refreshOutboundAuthToken() {
@@ -120,6 +122,8 @@ class Instance extends FetchableModel {
$this->auth->outboundToken = $data->token;
$this->save();
- (new RefreshOutboundAuthToken($this->domain, new \DateTimeImmutable($data->expires)))->submit();
+ // try to refresh it again 1 hour before it expires, to leave some leeway
+ $refreshAt = (new \DateTimeImmutable($data->expires))->sub(new \DateInterval('PT1H'));
+ (new RefreshOutboundAuthToken($this->domain, $refreshAt))->submit();
}
} \ No newline at end of file