Need some help with Deta Micros #274
-
So, I am making an api using deta micros and fastapi, I added api keys and I wanted to know how to use the api key in the url in the web browser without using code. example: https://api.deta.dev/endpoint?key=APIKEY HERE sorry for dumb question.. x'D |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
hi, this doesn't work. it is also insecure to put any secrets in the url, esp api keys. |
Beta Was this translation helpful? Give feedback.
-
Use from fastapi import FastAPI, Request
@app.get("/")
async def root(request: Request):
api_key = request.headers.get('X-API-KEY')
# do stuff with api_key here |
Beta Was this translation helpful? Give feedback.
Use
requesr.headers.get
to access the API KEY sent with request header ( example:{'X-API-KEY': YOUR_API_KEY}
)EXAMPLE: