Skip to content

Commit

Permalink
fix: Use provided national cloud as base url
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndiritu committed Dec 16, 2024
1 parent 80f8ab1 commit 4323b09
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 @@ -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);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/GraphServiceClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 4323b09

Please sign in to comment.