MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
276 stars 501 forks source link

User profile picture not rendered in adaptive card on Teams client app #9529

Closed Wajeed-msft closed 9 months ago

Wajeed-msft commented 10 months ago

Copied bug from: https://github.com/microsoft/AdaptiveCards/issues/8687

Details from original post:

Target Platforms

Other

SDK Version

Adaptive Cards 1.3

Application Name

Microsoft Teams

Problem Description

When adding the user profile picture with url "/_layouts/15/userphoto.aspx" to an adaptive card, it renders in Teams via browser but not in the client app, which returns a 401 Unauthorised.

URL for the image: https://TENANT.sharepoint.com/_layouts/15/userphoto.aspx?size=S&accountname=USER_EMAIL@TENANT.onmicrosoft.com

Screenshots

Teams in browser: Screenshot 2023-09-22 154948 Teams app: Screenshot 2023-09-22 154959

Card JSON

{
      "type": "AdaptiveCard",
      "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
      "version": "1.3",
      "body": [
        {
          "type": "Container",
          "items": [
            {
              "type": "ColumnSet",
              "spacing": "extraLarge",
              "columns": [
                {
                  "type": "Column",
                  "width": "36px",
                  "items": [
                    {
                      "type": "Image",
                      "url": "https://TENANT.sharepoint.com/_layouts/15/userphoto.aspx?size=S&accountname=USER_EMAIL@TENANT.onmicrosoft.com",
                      "width": "36px",
                      "style": "person"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }

Sample Code Language

No response

Sample Code

No response---

Document Details

Do not edit this section.It is required for docs.microsoft.com ➟ GitHub issue linking.

microsoft-github-policy-service[bot] commented 10 months ago

Hi Wajeed-msft! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

Meghana-MSFT commented 10 months ago

We will check this at our end, and it is rendering fine on both Teams Web and Teams desktop.

Could you please try with this URL once and let us know if you the same issue - https://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg?

image

z3019494 commented 10 months ago

This is still the case on my end in Teams 2.1

Meghana-MSFT commented 10 months ago

@z3019494 - Could you please let us know if you are facing the issue with the URL I shared in above comment?

Could you please try with this URL once and let us know if you the same issue - https://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg?

Ismael-Cruz commented 10 months ago

I opened this issue in another section and it was moved here. This issue happens when using URLs from SharePoint, like the profile picture (userphoto.aspx), I've seen it as well with images from the SiteAssets library. If you use a picture hosted in any public CDN it will work.

The picture appears in Teams browser only because of cached content, once refreshing clearing cache the image does not appear. There must be something when trying to access the image in SharePoint being in Teams context.

If it helps for anyone having this issue, as a workaround we download the image in base64 dynamically and send it in our adaptive card using the hostedContents property.

Meghana-MSFT commented 9 months ago

As you rightly said, when you try to load an image within Adaptive Card using sharepoint url in the browser, the user has a signed-in session to SharePoint, but perhaps that's not respected in the Teams client.

Please note that the URL should be a public image link.

microsoft-github-policy-service[bot] commented 9 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 3 days of this comment.