Add token expiration

This commit is contained in:
Emili Castells Guasch 2024-08-07 10:36:05 +02:00
parent 8411ef2106
commit 4f47b382c5
2 changed files with 6 additions and 3 deletions

View file

@ -110,7 +110,9 @@ class SdkClientToken {
}
$access_token = $json->access_token;
$this->cache->set( self::CACHE_KEY, $access_token );
$expires_in = (int) $json->expires_in;
$this->cache->set( self::CACHE_KEY, $access_token, $expires_in );
return $access_token;
}

View file

@ -115,9 +115,10 @@ class UserIdToken {
throw new PayPalApiException( $json, $status_code );
}
$id_token = $json->id_token;
$id_token = $json->id_token;
$expires_in = (int) $json->expires_in;
$this->cache->set( self::CACHE_KEY . '-' . (string) get_current_user_id(), $id_token );
$this->cache->set( self::CACHE_KEY . '-' . (string) get_current_user_id(), $id_token, $expires_in );
return $id_token;
}