1313use Psr \Log \LoggerInterface ;
1414use Psr \SimpleCache \CacheInterface ;
1515
16- /**
17- * Class BookboonOauthClient
18- * @package Bookboon\OauthClient\Client
19- */
20- class OauthClient implements OauthInterface
16+ class AccessTokenClient
2117{
18+ protected string $ _apiUri ;
19+ private ?AccessTokenInterface $ accessToken ;
20+ protected ?string $ act ;
21+ protected BookboonProvider $ provider ;
22+ protected array $ requestOptions = [];
23+ protected string $ apiId ;
24+ protected Headers $ headers ;
25+ protected ?CacheInterface $ cache ;
2226
23- const C_VERSION = '2.2 ' ;
24-
25- /** @var string */
26- protected $ _apiUri ;
27-
28- /** @var AccessTokenInterface|null */
29- private $ accessToken ;
30-
31- /** @var string|null */
32- protected $ act ;
33-
34- /** @var BookboonProvider */
35- protected $ provider ;
36-
37- /** @var array */
38- protected $ requestOptions = [];
39-
40- /** @var string */
41- protected $ apiId ;
42-
43- /** @var string */
44- protected $ apiSecret ;
45-
46- /** @var Headers */
47- protected $ headers ;
48-
49- /** @var CacheInterface|null */
50- protected $ cache ;
51-
52- /**
53- * ClientCommon constructor.
54- * @param string $apiId
55- * @param string $apiSecret
56- * @param Headers $headers
57- * @param array $scopes
58- * @param CacheInterface|null $cache
59- * @param string|null $redirectUri
60- * @param string|null $appUserId
61- * @param string|null $authServiceUri
62- * @param string|null $apiUri
63- * @param LoggerInterface|null $logger
64- * @param array $clientOptions
65- * @throws UsageException
66- */
6727 public function __construct (
6828 string $ apiId ,
6929 string $ apiSecret ,
@@ -151,12 +111,6 @@ public function requestAccessToken(
151111 return $ this ->accessToken ;
152112 }
153113
154-
155- /**
156- * @param AccessTokenInterface $accessToken
157- * @return AccessTokenInterface
158- * @throws IdentityProviderException
159- */
160114 public function refreshAccessToken (AccessTokenInterface $ accessToken ) : AccessTokenInterface
161115 {
162116 $ this ->accessToken = $ this ->provider ->getAccessToken ('refresh_token ' , [
@@ -166,20 +120,11 @@ public function refreshAccessToken(AccessTokenInterface $accessToken) : AccessTo
166120 return $ accessToken ;
167121 }
168122
169- /**
170- * @return string
171- */
172123 public function generateState (): string
173124 {
174125 return $ this ->provider ->generateRandomState ();
175126 }
176127
177- /**
178- * @param string $stateParameter
179- * @param string $stateSession
180- * @return boolean
181- * @throws ApiInvalidStateException
182- */
183128 public function isCorrectState (string $ stateParameter , string $ stateSession ) : bool
184129 {
185130 if (empty ($ stateParameter ) || ($ stateParameter !== $ stateSession )) {
@@ -189,10 +134,6 @@ public function isCorrectState(string $stateParameter, string $stateSession) : b
189134 return true ;
190135 }
191136
192- /**
193- * @param array $options
194- * @return string
195- */
196137 public function getAuthorizationUrl (array $ options = []): string
197138 {
198139 $ provider = $ this ->provider ;
@@ -204,12 +145,6 @@ public function getAuthorizationUrl(array $options = []): string
204145 return $ provider ->getAuthorizationUrl ($ options );
205146 }
206147
207-
208- /**
209- * @param string|null $uri
210- * @return string
211- * @throws \Bookboon\ApiBundle\Exception\UsageException
212- */
213148 protected function parseUriOrDefault (?string $ uri ) : string
214149 {
215150 $ protocol = ClientConstants::API_PROTOCOL ;
0 commit comments