using PHP GraphApiClient GraphApiClient($requestAdapter) return Exception of "invalid_client"

Test User 1 0 Reputation points
2023-08-19T00:02:54.17+00:00

I'm using the sample php code from here:
https://github.com/microsoft/kiota-samples/blob/main/get-started/azure-auth/php/GetUser.php

But after calling $me = $client->me()->get()->wait(); there is an Exception with messsage "invalid_client"

Am is using the right clientId?
Is there something I need to setup in the Registered App?

My Setup

I set the variables with the testing account.

$tenantId = 'common'
$clientId = The registered app client value
$clientSecret = The registered app secret
$redirectUri = Same URL as the registered app redirect url
$authorizationCode = The authendicatied code returned from https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=MY_CLIENT_ID&response_type=code&redirect_uri=%20http://localhost:8000/homepage.php&response_mode=query&scope=User.Read

User's image

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. Test User 1 0 Reputation points
    2023-08-21T16:57:20.0733333+00:00

    "invalid_client" is from an Exception message. That was all the information I got.

    When I try to look at the State of the promise, it returns "rejected". So it see like there is someting on Azure AD that is not set up properly.

    	$client = new GraphApiClient($requestAdapter);
    	
    	echo "Promise State: " . $client->me()->get()->getState();
    

    I belive my test user is set up correctly to access the applicationimage

    Is there any way to know the reason why it was "rejected"?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.