TheNetworg/oauth2-azure

Microsoft Graph suddenly not returning user profile attributes

malle-pietje opened this issue · 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?

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

What does the API response look like?