1212use GuzzleHttp \RequestOptions ;
1313use League \OAuth2 \Client \Grant \ClientCredentials ;
1414use League \OAuth2 \Client \Grant \Password ;
15- use League \OAuth2 \Client \Provider \AbstractProvider ;
1615use League \OAuth2 \Client \Token \AccessToken ;
1716use League \OAuth2 \Client \Token \AccessTokenInterface ;
1817use Platformsh \Client \Session \Session ;
@@ -30,7 +29,7 @@ class Connector implements ConnectorInterface
3029
3130 protected $ oauthMiddleware ;
3231
33- protected ?AbstractProvider $ provider = null ;
32+ protected ?Platformsh $ provider = null ;
3433
3534 protected SessionInterface $ session ;
3635
@@ -225,7 +224,7 @@ public function logIn(string $username, string $password, bool $force = false, i
225224 if ($ this ->isLoggedIn ()) {
226225 $ this ->logOut ();
227226 }
228- $ token = $ this ->getProvider ()->getAccessToken (new Password (), [
227+ $ token = $ this ->getOAuth2Provider ()->getAccessToken (new Password (), [
229228 'username ' => $ username ,
230229 'password ' => $ password ,
231230 'totp ' => $ totp ,
@@ -311,6 +310,19 @@ public function getClient(): ClientInterface
311310 return $ this ->client ;
312311 }
313312
313+ public function getOAuth2Provider (): Platformsh
314+ {
315+ return $ this ->provider ?: new Platformsh ([
316+ 'clientId ' => $ this ->config ['client_id ' ],
317+ 'clientSecret ' => $ this ->config ['client_secret ' ],
318+ 'token_url ' => $ this ->config ['token_url ' ],
319+ 'api_url ' => $ this ->config ['api_url ' ],
320+ 'debug ' => $ this ->config ['debug ' ],
321+ 'verify ' => $ this ->config ['verify ' ],
322+ 'proxy ' => $ this ->config ['proxy ' ],
323+ ]);
324+ }
325+
314326 /**
315327 * Load the current access token.
316328 */
@@ -363,7 +375,7 @@ protected function getOauthMiddleware(): GuzzleMiddleware|callable|null
363375 $ grantOptions ['api_token ' ] = $ this ->config ['api_token ' ];
364376 }
365377
366- $ this ->oauthMiddleware = new GuzzleMiddleware ($ this ->getProvider (), $ grant , $ grantOptions );
378+ $ this ->oauthMiddleware = new GuzzleMiddleware ($ this ->getOAuth2Provider (), $ grant , $ grantOptions );
367379 $ this ->oauthMiddleware ->setTokenSaveCallback (function (AccessToken $ token ) {
368380 $ this ->saveToken ($ token );
369381 });
@@ -451,17 +463,4 @@ private function revokeTokens(): void
451463 $ this ->getClient ()->request ('post ' , $ url , $ options );
452464 }
453465 }
454-
455- private function getProvider (): AbstractProvider |Platformsh
456- {
457- return $ this ->provider ?: new Platformsh ([
458- 'clientId ' => $ this ->config ['client_id ' ],
459- 'clientSecret ' => $ this ->config ['client_secret ' ],
460- 'token_url ' => $ this ->config ['token_url ' ],
461- 'api_url ' => $ this ->config ['api_url ' ],
462- 'debug ' => $ this ->config ['debug ' ],
463- 'verify ' => $ this ->config ['verify ' ],
464- 'proxy ' => $ this ->config ['proxy ' ],
465- ]);
466- }
467466}
0 commit comments