we having guest account accessing our app and reported issue. we pinpointed the issue that we cannot use User().email to build SharePoint claims. the workaround is the following code, noting that not every column that is returned by myProfileV2() is accessible to guest users so you have to use select for available columns for them or you will get 401 error. Lower(Office365Users.MyProfileV2({'$select': "userPrincipalName, mail, displayName"}).userPrincipalName)
This is a known limitation while handling guest users in Power Apps.
For guest users, User().Email does not return the correct UPN (User Principal Name) or valid SharePoint claims identity. (SharePoint Claims format: i:0#.f|membership|someone@example.com)
To retrieve the userPrincipalName for Guest Users, the code which you have used is correct.
By explicitly requesting just the accessible fields (userPrincipalName, mail, displayName) using $select, you not only avoid 401 Unauthorized errors from restricted properties, but also ensure compatibility across user types including guests.
If this reply helped you, please mark this reply as suggested answer ✔️ and give it a like to help others in the community find the answer too!
Thanks,
Vipul
Was this reply helpful?YesNo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.