How to pass header (token) in a streamlit (file_uploader) request?

:rotating_light: Before clicking “Create Topic”, please make sure your post includes the following information (otherwise, the post will be locked). :rotating_light:

  1. Are you running your app locally or is it deployed? No, on AWS EKS
  2. If your app is deployed:
    a. Is it deployed on Community Cloud or another hosting platform? AWS
    b. Share the link to the public deployed app. Its private app
  3. Share the link to your app’s public GitHub repository (including a [requirements file](https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/app-
    dependencies)).
    Its private app
  4. Share the full text of the error message (not a screenshot).
    Getting socket error while uploading a file greater that 15 MB. Root cause is authentication proxy which needs token in the header. I am not able to figure out how to pass header to st.file_uploader function or set before calling this function.
  5. Share the Streamlit and Python versions.
    streamlit==1.28.0
    Python 3.9

Hi @Sandeep_S

Is the following what you’re looking for, to perform a get request

token = 'xxxxxxxxxx'
r = requests.get(
        'https://url-address/',
        headers={
            'accept': 'application/xxxxxx',
            'authorization': 'token {}'.format(token)} )

Hope this helps!

Hi @dataprofessor Thanks for your reply on my question. I am using st.file_uploader function to upload a file which is making internal call to ‘_stcore/upload_file’ end point (https://app.com/_stcore/upload_file). I need to intercept this request and add a token to it for authentication. Is there a way to do that?

Hi

Yes you can take the uploaded file and convert it to a binary format and use that as input for your requests query

Sorry, I am still not sure on how to pass token in http header to streamlit upload function.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.