MS Graph PHP SDK fails to retrieve an access token
I am using the PHP microsoft/microsoft-graph package version 2.3.0, PHP version 8.2.5.
Following the examples described here: https://learn.microsoft.com/en-us/graph/sdks/create-client?tabs=php#tabpanel_1_php
My code fails when it tries to fetch the token with a malformed request. Only the tenant ID is put into the /token endpoint request, the client_id and other required parameters are not being set on the oauthProvider within PhpLeagueAccessTokenProvider.
Here is my code, as per the example:
$tokenRequestContext = new AuthorizationCodeContext(
$this->tenantId,
$this->clientId,
$this->clientSecret,
$this->getAccessToken()->__toString(), // Actual token or 'AUTH_CODE_FROM_REDIRECT'
$this->redirectUrl,
);
$provider = new GraphServiceClient($tokenRequestContext, self::AZURE_SCOPES);
$provider->me()->get()->wait();
The nesting of calls ending up in PhpLeagueAccessTokenProvider do not set the required parameters in the oauthProvider on line 94:
$this->oauthProvider = $oauthProvider ?? ProviderFactory::create($tokenRequestContext);
This merely sets the URLs and does not set the credentials within the provider resulting in an invalid request when calling the /token endpoint.
It looks like I am setting this up correctly according to all the documentation I've read, but the client credentials are just not being set in the requests.