Skip to content

Commit 37e4d46

Browse files
committed
fix: Mark nationalCloud constructor parameter in GraphPhpLeagueAuthenticationProvider as deprecated
1 parent 82598c5 commit 37e4d46

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Authentication/GraphPhpLeagueAuthenticationProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ class GraphPhpLeagueAuthenticationProvider extends PhpLeagueAuthenticationProvid
2424
/**
2525
* @param TokenRequestContext $tokenRequestContext
2626
* @param array<string> $scopes defaults to ["https://[graph national cloud host]/.default"] scope
27-
* @param string $nationalCloud defaults to https://graph.microsoft.com. See
28-
* https://learn.microsoft.com/en-us/graph/deployments
27+
* @param string $nationalCloud @deprecated Parameter is not passed up to the parent class. Use createWithAccessTokenProvider() instead
2928
*/
3029
public function __construct(
3130
TokenRequestContext $tokenRequestContext,
3231
array $scopes = [],
33-
string $nationalCloud = NationalCloud::GLOBAL
32+
string $nationalCloud = NationalCloud::GLOBAL // @deprecated parameter is not passed up to the parent class. Use createWithAccessTokenProvider() instead
3433
)
3534
{
3635
$accessTokenProvider = new GraphPhpLeagueAccessTokenProvider($tokenRequestContext, $scopes, $nationalCloud);

tests/Authentication/GraphPhpLeagueAuthenticationProviderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Microsoft\Graph\Core\Authentication\GraphPhpLeagueAccessTokenProvider;
66
use Microsoft\Graph\Core\Authentication\GraphPhpLeagueAuthenticationProvider;
7+
use Microsoft\Graph\Core\NationalCloud;
78
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
89
use PHPUnit\Framework\TestCase;
910

@@ -15,4 +16,12 @@ public function testSuccessfullyInitializesClass(): void
1516
$leagueAuthProvider = new GraphPhpLeagueAuthenticationProvider($context, []);
1617
$this->assertNotEmpty($leagueAuthProvider->getAccessTokenProvider()->getAllowedHostsValidator()->getAllowedHosts());
1718
}
19+
20+
public function testNationalCloudUrlIsUsed(): void
21+
{
22+
$context = new ClientCredentialContext('tenant', 'clientId', 'secret');
23+
$leagueAuthProvider = new GraphPhpLeagueAuthenticationProvider($context, [], NationalCloud::US_GOV);
24+
$this->assertEquals('https://login.microsoftonline.us/tenant/oauth2/v2.0/authorize', $leagueAuthProvider->getAccessTokenProvider()->getOauthProvider()->getBaseAuthorizationUrl());
25+
$this->assertEquals('https://login.microsoftonline.us/tenant/oauth2/v2.0/token', $leagueAuthProvider->getAccessTokenProvider()->getOauthProvider()->getBaseAccessTokenUrl([]));
26+
}
1827
}

0 commit comments

Comments
 (0)