Skip to content

Commit 5aacc24

Browse files
authored
Merge pull request #182 from microsoftgraph/fix/allow-passing-own-auth-provider
fix(auth): Add a parameter to allow the user to use a custom auth provider.
2 parents 26ce5bd + 5daeb2c commit 5aacc24

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

.github/workflows/pr-validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
matrix:
2121
php-versions: ['7.4', '8.1', '8.2', '8.3']
2222
steps:
23-
- uses: actions/[email protected].6
23+
- uses: actions/[email protected].7
2424
- name: Setup PHP
2525
uses: shivammathur/setup-php@v2
2626
with:
@@ -41,7 +41,7 @@ jobs:
4141
code-coverage:
4242
runs-on: ubuntu-latest
4343
steps:
44-
- uses: actions/[email protected].6
44+
- uses: actions/[email protected].7
4545
- name: Setup PHP and Xdebug for Code Coverage report
4646
uses: shivammathur/setup-php@v2
4747
with:

.github/workflows/update-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run-php-documentor:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/[email protected].6
18+
- uses: actions/[email protected].7
1919
with:
2020
ref: ${{ github.ref }}
2121

src/Authentication/GraphPhpLeagueAccessTokenProvider.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Microsoft\Graph\Core\Authentication;
1010

1111

12+
use League\OAuth2\Client\Provider\AbstractProvider;
1213
use Microsoft\Graph\Core\NationalCloud;
1314
use Microsoft\Kiota\Authentication\Cache\AccessTokenCache;
1415
use Microsoft\Kiota\Authentication\Oauth\ProviderFactory;
@@ -39,12 +40,14 @@ class GraphPhpLeagueAccessTokenProvider extends PhpLeagueAccessTokenProvider
3940
* @param string $nationalCloud Defaults to https://graph.microsoft.com. See
4041
* https://learn.microsoft.com/en-us/graph/deployments
4142
* @param AccessTokenCache|null $accessTokenCache Defaults to an in-memory cache if null
43+
* @param AbstractProvider|null $oauthProvider Your own oauth provider if you don't want to use the default.
4244
*/
4345
public function __construct(
4446
TokenRequestContext $tokenRequestContext,
4547
array $scopes = [],
4648
string $nationalCloud = NationalCloud::GLOBAL,
47-
?AccessTokenCache $accessTokenCache = null
49+
?AccessTokenCache $accessTokenCache = null,
50+
?AbstractProvider $oauthProvider = null
4851
)
4952
{
5053
$nationalCloud = empty($nationalCloud) ? NationalCloud::GLOBAL : $nationalCloud;
@@ -58,7 +61,7 @@ public function __construct(
5861
];
5962
$tokenBaseServiceUrl = self::NATIONAL_CLOUD_TO_AZURE_AD_ENDPOINT[$nationalCloud] ??
6063
self::NATIONAL_CLOUD_TO_AZURE_AD_ENDPOINT[NationalCloud::GLOBAL];
61-
$oauthProvider = ProviderFactory::create(
64+
$oauthProvider = $oauthProvider ?? ProviderFactory::create(
6265
$tokenRequestContext,
6366
[],
6467
$tokenBaseServiceUrl,
@@ -73,7 +76,7 @@ public function __construct(
7376
* @param AccessTokenCache $accessTokenCache
7477
* @param TokenRequestContext $tokenRequestContext
7578
* @param array<string> $scopes
76-
* @return GraphPhpLeagueAccessTokenProvider
79+
* @return self
7780
*/
7881
public static function createWithCache(
7982
AccessTokenCache $accessTokenCache,

0 commit comments

Comments
 (0)