Skip to content

Commit

Permalink
time jwt delay
Browse files Browse the repository at this point in the history
  • Loading branch information
maztch committed Mar 28, 2017
1 parent befb43b commit 7a9ea1b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Ilovepdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function getJWT()

// Collect all the data
$secret = $this->getSecretKey();

$currentTime = time();
$request = '';
$hostInfo = '';
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7a9ea1b

Please sign in to comment.