Authentication (Token check) before file upload
See original GitHub issueHow can i check ouath2 token before the file is uploaded?
In the current configuration the file is uploaded and then the dependency is called to check the token. Instead of wasting resources untill the file is completely uploaded (especially if it’s a big file) I would like to check the token before it completes the upload
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def upload_file(
user_id=Depends(verify_access_token),
ufiles: UploadFile = File(...),
):
return {"Hello": "World"}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Authenticate Web API session before body upload
Authentication is a simple challenge/response system using a token, so this means a client could easily upload several hundred megabytes of data ...
Read more >How to upload a file through an API? - YouTube
How to upload a file through an API? | Token -based Authentication. Watch later. Share. Copy link. Info. Shopping. Tap to unmute.
Read more >File upload / download and Basic / Bearer authentication ...
Before testing this example, you must full fill following requirements ; 1. Generate private and public keys pair in same directory as (testkey...
Read more >Authentication using Databricks personal access tokens
Bearer authentication. You can use this approach with ; curl or any client that you build. For the latter, see Upload a big...
Read more >Verify ID Tokens | Firebase Authentication - Google
Before you begin · Retrieve ID tokens on clients · Verify ID tokens using the Firebase Admin SDK · Verify ID tokens using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have you tried using an asynchronous function for this case ?
But does it really depend on the actual endpoint/middleware? Isn’t the file upload being the part of the request? Therefore only if the file is uploaded, the request is “complete” and sent to the server? I think that this is part of how HTTP works, not fastapi itself.