TheNetworg / oauth2-azure

Azure AD provider for the OAuth 2.0 Client.
https://packagist.org/packages/thenetworg/oauth2-azure
MIT License
229 stars 108 forks source link

Microsoft Graph suddenly not returning user profile attributes #207

Open malle-pietje opened 7 months ago

malle-pietje commented 7 months ago

Hi, we've been using this code in many installations of our software to provide OAuth2.0 login against Azure AD. We are currently on v2.2.1 of this excellent library.

At one site we are suddenly seeing that this code is no longer able to get data from the graph endpoint "/v1.0/me":

   $user            = $provider->get($provider->getRootMicrosoftGraphUri($token) . '/v1.0/me', $token);
   $user_first_name = $user['givenName'] ?? '';
   $user_last_name  = $user['surname'] ?? '';
   $user_full_name  = $user['displayName'] ?? '';
   $user_email      = $user['userPrincipalName'] ?? '';
   $user_profile_id = $user['id'] ?? '';

Either the properties don't exist at the endpoint or they are empty.

Has anyone seen this before and know what the cause can be?

decomplexity commented 7 months ago

It might be worth establishing whether $user['givenName'], say, is really not set or is empty, since ?? will be true in either case; if false $user_first_name will evaluate as empty anyway.

hajekj commented 7 months ago

What does the API response look like?