Search code examples
microsoft-graph-apisharepoint-onlinespfxazure-ad-b2b

SPFx web part with Graph API not returning Guest user companyName


Having assigned the User.Read.All permission to a SPFx web part, and Approving it in SPO Admin portal, and also making it a Configured permission (and consenting) it in AD App registration, I'm still not able to query properties such as companyName or postalCode or a Guest user, they always come back as null.

I'm using pnp-js to do the query, but same happens if I import the HTTP call to Postman and do the query manually, so there's nothing wrong (apparently) in the call: https://graph.microsoft.com/v1.0/users/first.last_domain.com%23EXT%23%somecompany.onmicrosoft.com?$select=id,companyName,displayName,givenName,surname,mail,postalCode

Do I need some additional permission to query non-basic Guest user profile properties?

enter image description here

enter image description here


Solution

  • I don't think it is related to permission, I think User.Read.All permission is enough. I test it in my side, it works fine. So please check if the two fields companyName and postalCode of the ad guest user is null on your azure portal. enter image description here

    Just guess your situation: Did you add the user from another tenant to current tenant as a guest user ? If so, in current tenant, it will not show the fields such as companyName and postalCode which shown in original tenant.