How can I pass an authentication header in the Image component

Vinicius Veras dos Santos 1 Reputation point

My images are in a protected url. How can I pass an authentication header in the Image component?

<Image HeightRequest="50" WidthRequest="50">
<UriImageSource Uri="http://localhost/api/produtos/9676151a-6ebd-4331-8540-17f04ebf6ee6" CacheValidity="10:00:00:00" />

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
1,400 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 19,971 Reputation points Microsoft Vendor

    Hello @Vinicius Veras dos Santos ,

    It is not supported in ImageSource currently. You could try to download the image file then load it.
    There are several threads discussed about this issue and a feature request at GitHub, you can see Allow custom headers to be used when ImageSource is a URI · Issue #1843. And you can follow the progress at MAUI Repro: set an HTTP user-agent header when downloading images · Discussion #11329 or create a feature request at
    (You can check the forum posts, there are several solutions, and some developers use a third-party library. I cannot recommend you using any third-party tools due to the policy)

    Best Regards,
    Wenyan Zhang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments