Skip to content

Commit

Permalink
fix: Use provided national cloud as base URL and map it to the correc…
Browse files Browse the repository at this point in the history
…t authentication endpoint
  • Loading branch information
Ndiritu committed Dec 16, 2024
1 parent 6aee108 commit 14adc14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/GraphServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ public function __construct(
parent::__construct($requestAdapter);
return;
}
parent::__construct(new GraphRequestAdapter(
$defaultRequestAdapter = new GraphRequestAdapter(
new GraphPhpLeagueAuthenticationProvider($tokenRequestContext, $scopes, $nationalCloud)
));
);
$defaultRequestAdapter->setBaseUrl("$nationalCloud/beta");
parent::__construct($defaultRequestAdapter);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/GraphServiceClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ function (RequestInterface $request) {
// cache is populated
$this->assertInstanceOf(AccessToken::class, $customCache->getTokenWithContext($tokenRequestContext));
}

public function testNationalCloudUsed(): void
+ {
+ $client = new GraphServiceClient(new ClientCredentialContext('tenant', 'client', 'secret'), [], NationalCloud::US_GOV);
+ $this->assertEquals(NationalCloud::US_GOV.'/beta', $client->getRequestAdapter()->getBaseUrl());
+ }
}

0 comments on commit 14adc14

Please sign in to comment.