@@ -126,7 +126,7 @@ abstract protected function getJsonWebKeySetUrl(): ?string;
126126 * @param array<string,mixed>|null $idToken
127127 * @param OAuth2GrantType::* $grantType
128128 */
129- abstract protected function receiveToken (AccessToken $ token , ?array $ idToken , string $ grantType ): void ;
129+ abstract protected function receiveToken (OAuth2AccessToken $ token , ?array $ idToken , string $ grantType ): void ;
130130
131131 public function __construct ()
132132 {
@@ -162,9 +162,9 @@ final protected function getRedirectUri(): ?string
162162 *
163163 * @param string[]|null $scopes
164164 */
165- final public function getAccessToken (?array $ scopes = null ): AccessToken
165+ final public function getAccessToken (?array $ scopes = null ): OAuth2AccessToken
166166 {
167- $ token = Cache::getInstance ()->getInstanceOf ($ this ->TokenKey , AccessToken ::class);
167+ $ token = Cache::getInstance ()->getInstanceOf ($ this ->TokenKey , OAuth2AccessToken ::class);
168168 if ($ token ) {
169169 if ($ this ->accessTokenHasScopes ($ token , $ scopes )) {
170170 return $ token ;
@@ -197,9 +197,9 @@ final public function getAccessToken(?array $scopes = null): AccessToken
197197 *
198198 * @param string[]|null $scopes
199199 */
200- private function accessTokenHasScopes (AccessToken $ token , ?array $ scopes ): bool
200+ private function accessTokenHasScopes (OAuth2AccessToken $ token , ?array $ scopes ): bool
201201 {
202- if ($ scopes && array_diff ($ scopes , $ token ->Scopes )) {
202+ if ($ scopes && array_diff ($ scopes , $ token ->getScopes () )) {
203203 return false ;
204204 }
205205 return true ;
@@ -209,7 +209,7 @@ private function accessTokenHasScopes(AccessToken $token, ?array $scopes): bool
209209 * If an unexpired refresh token is available, use it to get a new access
210210 * token from the provider if possible
211211 */
212- final protected function refreshAccessToken (): ?AccessToken
212+ final protected function refreshAccessToken (): ?OAuth2AccessToken
213213 {
214214 $ refreshToken = Cache::getString ("{$ this ->TokenKey }:refresh " );
215215 return $ refreshToken === null
@@ -225,7 +225,7 @@ final protected function refreshAccessToken(): ?AccessToken
225225 *
226226 * @param array<string,mixed> $options
227227 */
228- final protected function authorize (array $ options = []): AccessToken
228+ final protected function authorize (array $ options = []): OAuth2AccessToken
229229 {
230230 if (isset ($ options ['scope ' ])) {
231231 $ scopes = $ this ->filterScope ($ options ['scope ' ]);
@@ -237,9 +237,9 @@ final protected function authorize(array $options = []): AccessToken
237237 $ cache ->has ($ this ->TokenKey )
238238 || $ cache ->has ("{$ this ->TokenKey }:refresh " )
239239 ) {
240- $ lastToken = $ cache ->getInstanceOf ($ this ->TokenKey , AccessToken ::class);
240+ $ lastToken = $ cache ->getInstanceOf ($ this ->TokenKey , OAuth2AccessToken ::class);
241241 if ($ lastToken ) {
242- $ scopes = Arr::extend ($ lastToken ->Scopes , ...$ scopes );
242+ $ scopes = Arr::extend ($ lastToken ->getScopes () , ...$ scopes );
243243 }
244244 }
245245 $ cache ->close ();
@@ -265,7 +265,7 @@ final protected function authorize(array $options = []): AccessToken
265265 /**
266266 * @param array<string,mixed> $options
267267 */
268- private function authorizeWithClientCredentials (array $ options = []): AccessToken
268+ private function authorizeWithClientCredentials (array $ options = []): OAuth2AccessToken
269269 {
270270 // league/oauth2-client doesn't add scopes to client_credentials
271271 // requests
@@ -290,7 +290,7 @@ private function authorizeWithClientCredentials(array $options = []): AccessToke
290290 /**
291291 * @param array<string,mixed> $options
292292 */
293- private function authorizeWithAuthorizationCode (array $ options = []): AccessToken
293+ private function authorizeWithAuthorizationCode (array $ options = []): OAuth2AccessToken
294294 {
295295 if (!$ this ->Listener ) {
296296 throw new LogicException ('Cannot use the Authorization Code flow without a Listener ' );
@@ -380,7 +380,7 @@ private function requestAccessToken(
380380 string $ grantType ,
381381 array $ options = [],
382382 $ scope = null
383- ): AccessToken {
383+ ): OAuth2AccessToken {
384384 Console::debug ('Requesting access token with ' . $ grantType );
385385
386386 $ _token = $ this ->Provider ->getAccessToken ($ grantType , $ options );
@@ -419,21 +419,20 @@ private function requestAccessToken(
419419 ?? $ scope );
420420
421421 if (!$ scopes && $ grantType === OAuth2GrantType::REFRESH_TOKEN ) {
422- $ lastToken = Cache::getInstance ()->getInstanceOf ($ this ->TokenKey , AccessToken ::class);
422+ $ lastToken = Cache::getInstance ()->getInstanceOf ($ this ->TokenKey , OAuth2AccessToken ::class);
423423 if ($ lastToken ) {
424- $ scopes = $ lastToken ->Scopes ;
424+ $ scopes = $ lastToken ->getScopes () ;
425425 }
426426 }
427427
428- $ token = new AccessToken (
428+ $ token = new OAuth2AccessToken (
429429 $ accessToken ,
430- $ tokenType ,
431430 $ expires ,
432431 $ scopes ?: $ this ->getDefaultScopes (),
433432 $ claims
434433 );
435434
436- Cache::set ($ this ->TokenKey , $ token , $ token ->Expires );
435+ Cache::set ($ this ->TokenKey , $ token , $ token ->getExpires () );
437436
438437 if ($ idToken !== null ) {
439438 $ idToken = $ this ->getValidJsonWebToken ($ idToken , true );
0 commit comments