diff --git a/src/GraphServiceClient.php b/src/GraphServiceClient.php index b2a381ec699..4f08b999e91 100644 --- a/src/GraphServiceClient.php +++ b/src/GraphServiceClient.php @@ -45,9 +45,11 @@ public function __construct( parent::__construct($requestAdapter); return; } - parent::__construct(new GraphRequestAdapter(new GraphPhpLeagueAuthenticationProvider( + $defaultRequestAdapter = new GraphRequestAdapter(new GraphPhpLeagueAuthenticationProvider( $tokenRequestContext, $scopes, $nationalCloud - ))); + )); + $defaultRequestAdapter->setBaseUrl($nationalCloud.'/v1.0'); + parent::__construct($defaultRequestAdapter); } /** diff --git a/tests/GraphServiceClientTest.php b/tests/GraphServiceClientTest.php index 3b2a9265904..f0124252968 100644 --- a/tests/GraphServiceClientTest.php +++ b/tests/GraphServiceClientTest.php @@ -126,4 +126,10 @@ function (RequestInterface $request) { $this->assertInstanceOf(AccessToken::class, $newCache->getTokenWithContext($newTokenRequestContext)); $this->assertEquals($this->testJWT, $newCache->getTokenWithContext($newTokenRequestContext)->getToken()); } + + public function testNationalCloudUsed(): void + { + $client = new GraphServiceClient(new ClientCredentialContext('tenant', 'client', 'secret'), [], NationalCloud::US_GOV); + $this->assertEquals(NationalCloud::US_GOV.'/v1.0', $client->getRequestAdapter()->getBaseUrl()); + } }