99namespace Microsoft \Graph \Core \Authentication ;
1010
1111
12+ use League \OAuth2 \Client \Provider \AbstractProvider ;
1213use Microsoft \Graph \Core \NationalCloud ;
1314use Microsoft \Kiota \Authentication \Cache \AccessTokenCache ;
1415use Microsoft \Kiota \Authentication \Oauth \ProviderFactory ;
@@ -39,12 +40,14 @@ class GraphPhpLeagueAccessTokenProvider extends PhpLeagueAccessTokenProvider
3940 * @param string $nationalCloud Defaults to https://graph.microsoft.com. See
4041 * https://learn.microsoft.com/en-us/graph/deployments
4142 * @param AccessTokenCache|null $accessTokenCache Defaults to an in-memory cache if null
43+ * @param AbstractProvider|null $oauthProvider Your own oauth provider if you don't want to use the default.
4244 */
4345 public function __construct (
4446 TokenRequestContext $ tokenRequestContext ,
4547 array $ scopes = [],
4648 string $ nationalCloud = NationalCloud::GLOBAL ,
47- ?AccessTokenCache $ accessTokenCache = null
49+ ?AccessTokenCache $ accessTokenCache = null ,
50+ ?AbstractProvider $ oauthProvider = null
4851 )
4952 {
5053 $ nationalCloud = empty ($ nationalCloud ) ? NationalCloud::GLOBAL : $ nationalCloud ;
@@ -58,7 +61,7 @@ public function __construct(
5861 ];
5962 $ tokenBaseServiceUrl = self ::NATIONAL_CLOUD_TO_AZURE_AD_ENDPOINT [$ nationalCloud ] ??
6063 self ::NATIONAL_CLOUD_TO_AZURE_AD_ENDPOINT [NationalCloud::GLOBAL ];
61- $ oauthProvider = ProviderFactory::create (
64+ $ oauthProvider = $ oauthProvider ?? ProviderFactory::create (
6265 $ tokenRequestContext ,
6366 [],
6467 $ tokenBaseServiceUrl ,
@@ -73,7 +76,7 @@ public function __construct(
7376 * @param AccessTokenCache $accessTokenCache
7477 * @param TokenRequestContext $tokenRequestContext
7578 * @param array<string> $scopes
76- * @return GraphPhpLeagueAccessTokenProvider
79+ * @return self
7780 */
7881 public static function createWithCache (
7982 AccessTokenCache $ accessTokenCache ,
0 commit comments