This repository was archived by the owner on Aug 7, 2023. It is now read-only.
Need some help with Deta Micros #274
Answered
by
jnsougata
SlumberDemon
asked this question in
Help
|
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 |
Answered by
jnsougata
Jun 14, 2022
Replies: 2 comments 2 replies
|
hi, this doesn't work. it is also insecure to put any secrets in the url, esp api keys. |
1 reply
|
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 |
1 reply
Answer selected by
SlumberDemon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
requesr.headers.getto access the API KEY sent with request header ( example:{'X-API-KEY': YOUR_API_KEY})EXAMPLE: