Skip to content

Commit 6ea93b4

Browse files
committed
fix: Initialise access token provider with provided national cloud
1 parent 82598c5 commit 6ea93b4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Authentication/GraphPhpLeagueAuthenticationProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public function __construct(
3333
string $nationalCloud = NationalCloud::GLOBAL
3434
)
3535
{
36-
$accessTokenProvider = new GraphPhpLeagueAccessTokenProvider($tokenRequestContext, $scopes, $nationalCloud);
37-
parent::__construct($tokenRequestContext, $scopes, $accessTokenProvider->getAllowedHosts());
36+
$this->setAccessTokenProvider(new GraphPhpLeagueAccessTokenProvider($tokenRequestContext, $scopes, $nationalCloud));
3837
}
3938

4039
}

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)