token refreshment

This commit is contained in:
2021-02-13 16:57:36 +09:00
parent a550240f08
commit 8e42f49d8f

View File

@@ -89,7 +89,7 @@ class Esi {
$expires = $token->inserted_at + $token->expires_in; $expires = $token->inserted_at + $token->expires_in;
$tokenExpiration = Carbon::createFromTimestamp($expires)->toDateTimeString(); $tokenExpiration = Carbon::createFromTimestamp($expires)->toDateTimeString();
//If the access token has expired, we need to do a request for a new access token //If the access token has expired, we need to do a request for a new access token
if($currentTime > $token_expiration) { if($currentTime > $tokenExpiration) {
//Get the current scopes of the token //Get the current scopes of the token
$scopesArr = EsiScope::where([ $scopesArr = EsiScope::where([
'character_id' => $token->character_id, 'character_id' => $token->character_id,
@@ -158,6 +158,8 @@ class Esi {
$esi = null; $esi = null;
$config = config('esi'); $config = config('esi');
$tokenExpires = time() + $token->expires_in;
if($token == null) { if($token == null) {
$esi = new Eseye(); $esi = new Eseye();
} else { } else {
@@ -167,7 +169,7 @@ class Esi {
'secret' => $config['secret'], 'secret' => $config['secret'],
'refresh_token' => $token->refresh_token, 'refresh_token' => $token->refresh_token,
'access_token' => $token->access_token, 'access_token' => $token->access_token,
'token_expires' => $token_expiration, 'token_expires' => $tokenExpires,
]); ]);
//Setup the esi variable //Setup the esi variable