cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mengting
Level: Powered On

Office365Users.UserPhoto() AuthenticationError

Hi,

I am using Office365Users.UserPhoto() to retrive image of the employee. I tried all the possibilities below:

  1. Re-add the Office 365 User Data source
  2. I tried Office365Users.UserPhotoV2
  3. I tried different functions 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:
PowerappsUserPhotoError.JPG

 

PowerappsUserPhotoError2.jpg
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?

1 ACCEPTED SOLUTION

Accepted Solutions
Mengting
Level: Powered On

Re: Office365Users.UserPhoto() AuthenticationError

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.

 

https://microsoft.sharepoint.com/:i:/r/teams/appPlatform/PowerApps/PowerAppsClient/PhotoLibrary/Pict...? csf=1

 

 

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.

  1. Create a new SharePoint list.
  2. For each file you need to access, create an item.
  3. When creating the item, add the file as an attachment of the list item.
  4. On the PowerApps access the list item attachment and use it on a media control. For example: a. App has a gallery control. Gallery2.Items is set to "listmp3", where "listmp3" is a SharePoint list that has mp3 file attached to the items. There is one list item per file. b. App has an audio control . Audio1.Media is set to "First(Gallery2.Selected.Attachments).Value". This will obtain the attached file on the item selected on Gallery2.

 

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.

10 REPLIES 10
ZePowerDiver
Level 8

Re: Office365Users.UserPhoto() AuthenticationError

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.

Mengting
Level: Powered On

Re: Office365Users.UserPhoto() AuthenticationError

Hi @ZePowerDiver ,

 

Thank you for reply. More detail about the setting is:

I have one Gallery (Gallery21_3) and a Sub-Gallery (Gallery22)

DAProblem2.PNG

 

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:

DAProblem3.png

 

The function actually works fine, but the Error message always pops up.

 

Community Support Team
Community Support Team

Re: Office365Users.UserPhoto() AuthenticationError

Hi @Mengting ,

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:

https://powerusers.microsoft.com/t5/General-Discussion/quot-Call-Office365Users-UserPhotoMetadata-fa...

 

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mengting
Level: Powered On

Re: Office365Users.UserPhoto() AuthenticationError

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? 

 

  • 65c411f6-d4b8-4df6-a6a4-34ab9ee4d079
  • de590b80-08b9-4759-8258-c1141131aaaf
  • 934e9954-af34-4727-956a-743d647beb6b

No way to find them based on the userID.

 

Best regards,

MT

Mengting
Level: Powered On

Re: Office365Users.UserPhoto() AuthenticationError

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? 

 

  • 65c411f6-d4b8-4df6-a6a4-34ab9ee4d079
  • de590b80-08b9-4759-8258-c1141131aaaf
  • 934e9954-af34-4727-956a-743d647beb6b

No way to find them based on the invalid userID.

 

Best regards,

MT

Community Support Team
Community Support Team

Re: Office365Users.UserPhoto() AuthenticationError

Hi @Mengting ,

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mengting
Level: Powered On

Re: Office365Users.UserPhoto() AuthenticationError

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

 

DAProblem4.PNG

 

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

Community Support Team
Community Support Team

Re: Office365Users.UserPhoto() AuthenticationError

Hi @Mengting ,

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mengting
Level: Powered On

Re: Office365Users.UserPhoto() AuthenticationError

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

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 382 members 4,851 guests
Please welcome our newest community members: