You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which means that if, for ex; N users do a Viva::orders()->create call -> N authentication calls to Viva would happen. Each request would use a different token.
Shouldn't the authentication call be done once, then refresh when it expires? Probably store it using cache or something equivalent.
The text was updated successfully, but these errors were encountered:
The token is stored in memory, which means in the current lifecycle the same token is being used, because the Client is a singleton.
If you want to store the token until it expires, you have to cache it like this:
// get the token from the cache or store it until it expires$token = Cache::get('viva.token', function () {
$token = Viva::oauth()->requestToken();
Cache::put('viva.token', $token->access_token, $token->expires_in);
return$token->access_token;
});
// set the token to the client
Viva::withToken($token);
As far as I understand the token is stored in memory
laravel-viva-payments/src/Client.php
Lines 221 to 230 in 52796a9
Which means that if, for ex; N users do a
Viva::orders()->create
call -> N authentication calls to Viva would happen. Each request would use a different token.Shouldn't the authentication call be done once, then refresh when it expires? Probably store it using
cache
or something equivalent.The text was updated successfully, but these errors were encountered: