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.
I was getting this same error and mine is definitely due to this: as noted in Anonymous' response.
My app was displaying this UserPhotoV2 id error when I first view the Gallery of my SP list items. My Gallery shows my user's pic, email, etc. for IT tickets.
I found another option to somewhat get around this: don't use UserPhotoV2 at all! (This only works after you have already patched, added items to your SP list, etc.)
In your SP list, have a column that is set to a Person or Group. When I submit/save a ticket using the app, I have the user's email and Patch, with this code
{EndUserInfo : {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
Claims: "i:0#.f|membership|" & emailtext_1.Text,
DisplayName:emailtext_1.Text,
Email: emailtext_1.Text,
JobTitle: "",
Picture: ""}},
Note: EndUserInfo is my field/column in the SP list and my users' email is emailtext_1, etc.
Now in the Gallery view, I have the user's image set to:
ThisItem.EndUserInfo.Picture
It gets the Picture from the above Patch.
Now, I would have liked to show the user's picture as soon as it is selected from my dropdown and not get the Photo id error, but that is not working.
All other Office365Users items do not seem to produce this error. I can get many other values with that code and no error.
Using Monitor while playing the app shows the reference to the url with everything from the "@xxxxxxxx.xxx", which Anonymous refers to.
Thanks!! This one worked for me perfectly!
If(!IsBlank(ThisItem.Id),If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=false,SampleImage,Office365Users.UserPhotoV2(ThisItem.Id)))
There is an easy way to get the Photo of a User (Office 365)
If(!IsBlankOrError(ThisItem.Email) && !IsBlankOrError('Utilisateursd’Office365'.UserPhotoV2(ThisItem.Email)); 'Utilisateursd’Office365'.UserPhotoV2(ThisItem.Email);SampleImage)
This code Worked for me.
Hope it can help