Skip to content

Commit 14adc14

Browse files
committed
fix: Use provided national cloud as base URL and map it to the correct authentication endpoint
1 parent 6aee108 commit 14adc14

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/GraphServiceClient.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ public function __construct(
4444
parent::__construct($requestAdapter);
4545
return;
4646
}
47-
parent::__construct(new GraphRequestAdapter(
47+
$defaultRequestAdapter = new GraphRequestAdapter(
4848
new GraphPhpLeagueAuthenticationProvider($tokenRequestContext, $scopes, $nationalCloud)
49-
));
49+
);
50+
$defaultRequestAdapter->setBaseUrl("$nationalCloud/beta");
51+
parent::__construct($defaultRequestAdapter);
5052
}
5153

5254
/**

tests/GraphServiceClientTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,10 @@ function (RequestInterface $request) {
121121
// cache is populated
122122
$this->assertInstanceOf(AccessToken::class, $customCache->getTokenWithContext($tokenRequestContext));
123123
}
124+
125+
public function testNationalCloudUsed(): void
126+
+ {
127+
+ $client = new GraphServiceClient(new ClientCredentialContext('tenant', 'client', 'secret'), [], NationalCloud::US_GOV);
128+
+ $this->assertEquals(NationalCloud::US_GOV.'/beta', $client->getRequestAdapter()->getBaseUrl());
129+
+ }
124130
}

0 commit comments

Comments
 (0)