# st.file\_uploader with Azure Active Directory - error 403 \[August 2023\]

**URL:** <https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913>\
**Category:** Deployment\
**Created:** [August 23, 2023, 8:28am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913 "2023-08-23T08:28:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [August 23, 2023, 8:28am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/1 "2023-08-23T08:28:31Z")

</div>

Good morning!

I noticed recently (August?) that I am not able anymore to upload files on my Web App.

It is deployed on Microsoft Azure and it ensures that only people from my organisation have access to it via Azure Active Directory.  
Until August 2023, I was using the workaround: enableXsrfProtection = false (which was fine for the uploading).

Since August, this is no longer working.

Any idea how to proceed? Thank you very much!

---

<div class="post-metadata">

**Author:** ![aelbadry](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@aelbadry](https://discuss.streamlit.io/u/aelbadry)\
**Post date:** [August 25, 2023, 2:08pm UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/2 "2023-08-25T14:08:25Z")

</div>

Hi, I am encountering the same issue as well. Uploading works as long as authentication via Azure Active Directory is turned off. Once it is enabled, I can no longer upload files on my app. The workaround doesn’t work with me either. Thanks for bringing the issue to light!

---

<div class="post-metadata">

**Author:** ![marduk](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/marduk/32/11690_2.png) [@marduk](https://discuss.streamlit.io/u/marduk)\
**Post date:** [August 26, 2023, 7:10pm UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/3 "2023-08-26T19:10:13Z")

</div>

Hi @aelbadry , @Adlef ,

Can you try using Streamlit v1.26.0? Several bug fixes related to the `st.file_uploader` were merged recently, so maybe using this latest Streamlit version helps. Let me know!

---

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [August 28, 2023, 6:52am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/4 "2023-08-28T06:52:28Z")

</div>

Hi @marduk,

I tried with the new version of streamlit 1.26.0 but unfortunately it didn’t change anything ☹, even with the workaround implemented.

---

<div class="post-metadata">

**Author:** ![aelbadry](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@aelbadry](https://discuss.streamlit.io/u/aelbadry)\
**Post date:** [August 28, 2023, 7:35am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/5 "2023-08-28T07:35:56Z")

</div>

> [@marduk](#):
>
> v1.26.0

Hi @marduk,

The issue is still persisting with the updated version.

---

<div class="post-metadata">

**Author:** ![marduk](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/marduk/32/11690_2.png) [@marduk](https://discuss.streamlit.io/u/marduk)\
**Post date:** [August 28, 2023, 10:13am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/6 "2023-08-28T10:13:50Z")

</div>

Thank you both for checking! Just had a better look and this issue is frequently discussed on the forum. (My guess is that an HTTP request is triggered when a user attempts to upload a file, and that request isn’t picking up on the Azure Active Directory authorization headers.)

Not sure if this works, but a user in one thread recommends the following configuration in the `.streamlit/config.toml` file:

[server]  
enableXsrfProtection = false  
enableCORS = false

> [@File upload fails with Error: Request failed with status code 403](https://discuss.streamlit.io/t/file-upload-fails-with-error-request-failed-with-status-code-403/27143/31):
>
> Yes! You need to add this on the config.tml file: [server] enableXsrfProtection = false enableCORS = false That worked for me. More on config files: [Configuration - Streamlit Docs](https://docs.streamlit.io/library/advanced-features/configuration)

---

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [August 28, 2023, 10:43am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/7 "2023-08-28T10:43:35Z")

</div>

This was also done. The application stops running and gets a reset when the option enableXsrfProtection=false.

I even checked the log of my webapp on Azure:  
“container X for Y site is unhealthy, stopping site.”

Then, the WebApp is again pulling the image and restarts the whole thing.

---

<div class="post-metadata">

**Author:** ![Livia\_Meinhardt](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/livia_meinhardt/32/21342_2.png) [@Livia\_Meinhardt](https://discuss.streamlit.io/u/Livia_Meinhardt)\
**Post date:** [August 28, 2023, 1:10pm UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/8 "2023-08-28T13:10:42Z")

</div>

Just want to add that this worked for me on a slightly different problem. I was getting an error when uploading a file on a streamlit embeded with IFRAME and it was all on the local network.

---

<div class="post-metadata">

**Author:** ![Alexandre\_Dumont](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/alexandre_dumont/32/30115_2.png) [@Alexandre\_Dumont](https://discuss.streamlit.io/u/Alexandre_Dumont)\
**Post date:** [August 30, 2023, 11:35am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/9 "2023-08-30T11:35:19Z")

</div>

> [@Adlef](#):
>
> Microsoft Azure and it ensures that only people from my organisation have access to it via Azure Active Directory

We were facing the same issue today, also on Azure, with Azure AD Authentication enabled.

We’ve upgraded to streamlit 1.26.0 in our requirements.txt.  
We’ve disabled XsrfProtection and CORS in our config.toml, which now reads like this (in case the other options are also interesting to anyone?)

[server]  
runOnSave = true  
enableStaticServing = true  
enableXsrfProtection = false  
enableCORS = false

After those two changes, it is working, no more error 403 upon uploading the files.

Hope that helps!

Also, I’ve noticed that in the Azure webapp settings there a section about CORS. Ours looks like this:

 ![image](https://global.discourse-cdn.com/streamlit/original/3X/b/d/bdea0bd43267be7c5ed4f733a84a4289cf478815.png)

---

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [August 30, 2023, 1:35pm UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/10 "2023-08-30T13:35:54Z")

</div>

Unfortunately, I followed the same without success:

[server]  
runOnSave = true  
enableStaticServing = true  
enableXsrfProtection = false  
enableCORS = false

CORS disabled as in your screenshot in Azure.

When I try to upload a file, the app stops and starts again from beginning ☹

Thanks anyway for the help!

---

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [September 7, 2023, 7:24am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/11 "2023-09-07T07:24:45Z")

</div>

Unfortunately, after all recommendations here I am not able to solve the issue ☹ .

Anyone has a clue about the different settings to do on Azure side?

Thank you!

---

<div class="post-metadata">

**Author:** ![aelbadry](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@aelbadry](https://discuss.streamlit.io/u/aelbadry)\
**Post date:** [September 11, 2023, 11:28am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/12 "2023-09-11T11:28:42Z")

</div>

I am still having the issue as well and none of the recommendations worked either.

---

<div class="post-metadata">

**Author:** ![Nicolas\_Lee](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/nicolas_lee/32/32314_2.png) [@Nicolas\_Lee](https://discuss.streamlit.io/u/Nicolas_Lee)\
**Post date:** [September 21, 2023, 1:36am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/13 "2023-09-21T01:36:45Z")

</div>

Bump, same issue here as well. Followed the creation and two lines to the config.toml, published to Azure Web app, ensured the CORs setting was the same and still having the same problem.

---

<div class="post-metadata">

**Author:** ![brunobraga](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/brunobraga/32/35864_2.png) [@brunobraga](https://discuss.streamlit.io/u/brunobraga)\
**Post date:** [November 5, 2023, 7:40am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/15 "2023-11-05T07:40:13Z")

</div>

+1

Also experiencing the same issue. Tried the steps above with no luck.

Anyone found any resolution to this?

Thanks

---

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [November 10, 2023, 10:11am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/16 "2023-11-10T10:11:48Z")

</div>

I can’t explain how and why but by performing an update of all my python packages involved in my appplication I am now able to process any document on Azure cloud.

Additionally here are my settings (in config.toml):

[server]  
enableXsrfProtection = false  
enableCORS = false  
[browser]  
gatherUsageStats = false

---

<div class="post-metadata">

**Author:** ![brunobraga](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/brunobraga/32/35864_2.png) [@brunobraga](https://discuss.streamlit.io/u/brunobraga)\
**Post date:** [November 15, 2023, 1:40pm UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/17 "2023-11-15T13:40:41Z")

</div>

Thanks for sharing.  
How did you upgrade your packages? I do it cia CI/CD and it is  
My understanding all gets reinstated from scratch in every deployment. Unfortunately last time I tried these settings it still didn’t work.

---

<div class="post-metadata">

**Author:** ![brunobraga](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/brunobraga/32/35864_2.png) [@brunobraga](https://discuss.streamlit.io/u/brunobraga)\
**Post date:** [November 16, 2023, 2:08am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/18 "2023-11-16T02:08:34Z")

</div>

Update: Just did another update with your settings and it then worked, woohoo!

---

<div class="post-metadata">

**Author:** ![Hammad\_Zaki](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/hammad_zaki/32/37608_2.png) [@Hammad\_Zaki](https://discuss.streamlit.io/u/Hammad_Zaki)\
**Post date:** [January 21, 2024, 4:22pm UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/19 "2024-01-21T16:22:21Z")

</div>

hey did you solve the issue?

---

<div class="post-metadata">

**Author:** ![Adlef](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/adlef/32/28592_2.png) [@Adlef](https://discuss.streamlit.io/u/Adlef)\
**Post date:** [April 16, 2024, 8:59am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/20 "2024-04-16T08:59:01Z")

</div>

Yes, it has been solved. 🙂

---

<div class="post-metadata">

**Author:** ![derek.loots](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/derek.loots/32/46793_2.png) [@derek.loots](https://discuss.streamlit.io/u/derek.loots)\
**Post date:** [July 26, 2024, 11:28am UTC](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913/21 "2024-07-26T11:28:13Z")

</div>

I am still having this issue as well, I am on streamlit version 1.36.0 and my toml looks like this:

[server]  
runOnSave = true  
enableStaticServing = true  
enableXsrfProtection = false  
enableCORS = false

once I remove Azure Active Directoy Authentication it works but with it on it fails …

[Next page](https://discuss.streamlit.io/t/st-file-uploader-with-azure-active-directory-error-403-august-2023/49913.md?page=2)
