Hi,
I am using Office365Users.UserPhoto() to retrive image of the employee. I tried all the possibilities below:
If(!IsBlank(ThisItem.Id),If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhoto(ThisItem.Id))) If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhoto(ThisItem.Id)) If(!IsBlank(Id),If(Office365Users.UserPhotoMetadata(Id).HasPhoto=false,SampleImage,Office365Users.UserPhoto(Id))) Office365Users.UserPhoto(ThisItem.Id)
If(!IsBlank(ThisItem.Id),If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhotoV2(ThisItem.Id))) If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhotoV2(ThisItem.Id)) If(!IsBlank(Id),If(Office365Users.UserPhotoMetadata(Id).HasPhoto=false,SampleImage,Office365Users.UserPhotoV2(Id))) Office365Users.UserPhotoV2(ThisItem.Id)
Always have different Error message pops up:
When using Office365Users.UserPhotoV2(ThisItem.Id), got the error below:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "0a63db95-a309-494f-89fb-8284bfdc2fa7", "date": "2019-04-11T15:00:38" } } }
When using If(!IsBlank(Id),If(Office365Users.UserPhotoMetadata(Id).HasPhoto=false,SampleImage,Office365Users.UserPhotoV2(Id))), got the error below:
Office365Users.UserPhotoMetadata failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "58e84667-373e-416a-bb20-c6ca716c1a5b", "date": "2019-04-11T15:06:10" } } }
When using Office365Users.UserPhoto(ThisItem.Id), got the error below:
Office365Users.UserPhoto failed: { "status": 400, "message": "One or more input values is invalid.\r\nclientRequestId: 804fe1a5-c00b-4b8c-8d19-564a5b225aca", "source": "office365users-ne.azconn-ne.p.azurewebsites.net" }
When using
If(!IsBlank(ThisItem.Id),If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhoto(ThisItem.Id))) got the error below:
Office365Users.UserPhotoMetadata failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "83402233-bfe7-4642-8863-48f30a964f58", "date": "2019-04-11T15:13:18" } } }
When using
If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhoto(ThisItem.Id)) got the error below:
Office365Users.UserPhotoMetadata failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "a99d3f39-5eea-4545-94f8-8e36dc33ec86", "date": "2019-04-11T15:15:00" } } }
Mobile phone app shows error below:
etc.
I want to avoid the error message. All the function work fine, but still the error messages always come out, very annoying, and I don't know how to interpret the error message and don't know how to fix the error.
Can anybody help? How can I fix the AuthenticationError?
Solved! Go to Solution.
I get the right answer from a Microsoft Support as below. But the issue is not resolved, instead I post an idea in the community: https://powerusers.microsoft.com/t5/Flow-Ideas/PowerApps-Office365Users-UserPhoto-AuthenticationErro...
Description of root cause
The reason the images would not show are usually because the URL that is used to get the image is a url to the actual site on SPO. e.g.
When PowerApps binds an Image control to this URL, the request for the image is NOT authenticated.
Only URLs that come from supported data types from within the SharePoint connector get rewritten so that PowerApps will be able to authenticate them safely.
Why does it work in browsers (sometimes) then?
The reason it can sometimes work in browsers (e.g. when using Web Authoring or Web Player) is that browsers utilize cookies to perform authentication.
So when the browser makes the request to the sharepoint.com URL, it's not using PowerApps authentication tokens to authorize the request; it's using cookies stored by the browser for that domain.
Mitigations
Method 1 - Add the files as SharePoint list attachments.
My reason why this issue couldn't be resolved, because my company has 500+ employees, it’s hard for me to create a separate database for employee items with image as attachment. And it is double work, if the information is already existing somewhere, and I should utilize the existing information.
Hello Mengting,
have you validated the value of "ThisItem.Id" as being valid for the lookup of the User? It has to be the User Principal Name (UPN) or email id.
Hi @ZePowerDiver ,
Thank you for reply. More detail about the setting is:
I have one Gallery (Gallery21_3) and a Sub-Gallery (Gallery22)
Gallery21_3.Items Data source are from a SharePoint list (EmployeeEmailSharePointList), with employee's emails
Columns: Employee's name and their email
EmployeeEmailSharePointList
Gallery22.Items Data source is the search result based on the employee's email
Office365Users.SearchUser({searchTerm:ThisItem.Email})
In Gallery22 I want to display the user's image and only Image22 control is in the Gallery
Function in Image22.Image:
If(!IsBlank(ThisItem.Id),If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhotoV2(ThisItem.Id)))
The combination of the Gallery and sub-gallery looks like below:
The function actually works fine, but the Error message always pops up.
Hi @Anonymous ,
It is an known issue with the Office365Users.UserPhotoMetadata() function within PowerApps. The user @mikesglks has faced similar issue with you, please check the response within the following thread:
Currently, if you want to display the profile image of a specific user in your Org, please take a try with the following formula:
Office365Users.UserPhotoV2(id)
On your side, you should type:
Office365Users.UserPhotoV2(ThisItem.UserPrincipalName)
Or
Office365Users.UserPhotoV2(ThisItem.Id)
Currently, within PowerApps, we could not use the Office365Users.UserPhotoMetadata() function to detect if a user owns a profile image.
The product team is working to fix this issue, if the issue is solved, I would reply here.
Best regards,
Hi @v-xida-msft ,
Thank you very much for your reply
When I try:
Office365Users.UserPhotoV2(ThisItem.Id)
I get below error:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "65c411f6-d4b8-4df6-a6a4-34ab9ee4d079", "date": "2019-04-16T06:56:03" } } }
When I try:
Office365Users.UserPhotoV2(id)
I get below error:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "de590b80-08b9-4759-8258-c1141131aaaf", "date": "2019-04-16T06:58:34" } } } Location
When I try:
Office365Users.UserPhotoV2(ThisItem.UserPrincipalName)
I get below error:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "934e9954-af34-4727-956a-743d647beb6b", "date": "2019-04-16T07:00:08" } } }
I think here is some different error in my Office 365 tenant, that is the "AuthenticationError" with different request-id. Are these userID of some invalid users in my tenant?
No way to find them based on the userID.
Best regards,
MT
Hi @v-xida-msft ,
Thank you very much for your reply
When I try:
Office365Users.UserPhotoV2(ThisItem.Id)
I get below error:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "65c411f6-d4b8-4df6-a6a4-34ab9ee4d079", "date": "2019-04-16T06:56:03" } } }
When I try:
Office365Users.UserPhotoV2(id)
I get below error:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "de590b80-08b9-4759-8258-c1141131aaaf", "date": "2019-04-16T06:58:34" } } }
When I try:
Office365Users.UserPhotoV2(ThisItem.UserPrincipalName)
I get below error:
Office365Users.UserPhotoV2 failed: { "error": { "code": "AuthenticationError", "message": "Error authenticating with resource", "innerError": { "request-id": "934e9954-af34-4727-956a-743d647beb6b", "date": "2019-04-16T07:00:08" } } }
I think there is some different error in my Office 365 tenant, that is the "AuthenticationError" with different request-id. Are these userID of some invalid users in my tenant?
No way to find them based on the invalid userID.
Best regards,
MT
Hi @Anonymous ,
Based on the error message that you provided, I think there is something wrong with the Office 365 Users connection you created within your app.
Please consider take a try to re-create a new connection to Office 365 Users connector from your app, then try your formula again, check if the authentication issue has been fixed.
Best regards,
Thank you @v-xida-msft
I tried to delete the Office365 Users connector and add it again. The same error occur with different request-id
Is there any way I can do a cleaning to the office365 Users database as a Global Admin? I cannot find those invalid user, or I don't even sure if these are invalid userID.
Best regards,
MT
Hi @Anonymous ,
Is your Office 365 account not a Global Administrator within your Organization?
Currently, there is no way to assign Global Admin permission for a Office 365 user within a PowerApps app.
As an alternative solution, you could consider ask your Office 365 Administrator to assign Global Administrator role to your account within Office 365 Admin center.
Best regards,
Hi @v-xida-msft
Thank you for reply 🙂
Yes, I am Global Administrator. But I still cannot find the root cause of the AuthenticationError problem.
There is not so good search function in the Office 365 Admin center or in the SharePoint Admin center to search the probable invalid User only based on UserId.
It's hard for me to troubleshoot on the user issue, since I am not a programmer like I don't know much PowerShall (if there is solution to do with running PowerShall of course I can try).
Best regards,
MT