Skip to content

Commit

Permalink
fix: re-init client when token refreshed
Browse files Browse the repository at this point in the history
  • Loading branch information
mitulgolakiya committed Jun 5, 2022
1 parent 956c02c commit deeca48
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Managers/AuthManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use GuzzleHttp\Client;
use InfyOmLabs\LaravelEnvato\Auth\EnvatoCredentials;
use InfyOmLabs\LaravelEnvato\Client\EnvatoClient;
use InfyOmLabs\LaravelEnvato\Events\EnvatoCredentialsRefreshed;
use InfyOmLabs\LaravelEnvato\Utils\LaravelEnvatoUtils;

Expand Down Expand Up @@ -112,6 +113,11 @@ public function refreshToken()
$responseBody = json_decode((string) $response->getBody(), true);
$this->authCredentials->accessToken = $responseBody['access_token'];
$this->authCredentials->expiresIn = Carbon::now()->addSeconds($responseBody['expires_in']);

/** @var EnvatoClient $envatoClient */
$envatoClient = app(EnvatoClient::class);
$envatoClient->initClient();

EnvatoCredentialsRefreshed::dispatch($this->authCredentials);

return $this->authCredentials;
Expand Down

0 comments on commit deeca48

Please sign in to comment.