From 7a9ea1b1f370b68187373799015173160240137c Mon Sep 17 00:00:00 2001 From: Aleix Cabistany Date: Tue, 28 Mar 2017 17:37:37 +0200 Subject: [PATCH] time jwt delay --- src/Ilovepdf.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Ilovepdf.php b/src/Ilovepdf.php index e22c788..4d62dd0 100644 --- a/src/Ilovepdf.php +++ b/src/Ilovepdf.php @@ -101,6 +101,7 @@ public function getJWT() // Collect all the data $secret = $this->getSecretKey(); + $currentTime = time(); $request = ''; $hostInfo = ''; @@ -110,9 +111,9 @@ public function getJWT() $token = array_merge([ 'iss' => $hostInfo, 'aud' => $hostInfo, - 'iat' => $currentTime, - 'nbf' => $currentTime, - 'exp' => $currentTime + 3600 + 'iat' => $currentTime - 600, //add some "delay" + 'nbf' => $currentTime - 600, //add some "delay" + 'exp' => $currentTime + 3600 + 600 ////add some "delay" ], []); // Set up id @@ -168,6 +169,8 @@ public function sendRequest($method, $endpoint, $body=null) ), $body); if ($response->code != '200' && $response->code != '201') { if ($response->code == 401) { + var_dump($to_server); + var_dump($response); throw new AuthException($response->body->error->message, $response->code, null, $response); } elseif ($response->code == 401) {