Skip to content

Commit

Permalink
Fix Outh2 refresh token (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstantBqt authored Jul 23, 2024
1 parent 6e9957b commit 8060494
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Bynder/Api/Impl/OAuth2/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Bynder\Api\Impl\OAuth2;

use Bynder\Api\Impl\Oauth2\BynderOauthProvider;
use League\OAuth2\Client\Token\AccessToken;

/**
* Class to hold Oauth2 tokens necessary for every API request.
Expand Down Expand Up @@ -122,11 +123,18 @@ public function refreshToken(BynderOauthProvider $oauthProvider)
return;
}

$this->setToken(
$oauthProvider->getAccessToken('refresh_token', [
'refresh_token' => $this->getToken()->getRefreshToken()
])
);
$oldRefreshToken = $this->getToken()->getRefreshToken();

$token = $oauthProvider->getAccessToken('refresh_token', [
'refresh_token' => $oldRefreshToken
]);

$options = $token->jsonSerialize();
if (empty($options['refresh_token'])) {
$options['refresh_token'] = $oldRefreshToken;
}

$this->setToken(new AccessToken($options));
}

public function getRequestOptions()
Expand Down

0 comments on commit 8060494

Please sign in to comment.