oauth2-azure icon indicating copy to clipboard operation
oauth2-azure copied to clipboard

Microsoft Graph suddenly not returning user profile attributes

Open malle-pietje opened this issue 1 year ago • 2 comments

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?

malle-pietje avatar Dec 08 '23 16:12 malle-pietje

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.

decomplexity avatar Dec 08 '23 19:12 decomplexity

What does the API response look like?

hajekj avatar Dec 19 '23 12:12 hajekj