mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-23 21:42:16 -05:00
12 lines
270 B
Python
12 lines
270 B
Python
from fastapi import Depends, FastAPI
|
|
from fastapi.security import OAuth2PasswordBearer
|
|
|
|
app = FastAPI()
|
|
|
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(token: str = Depends(oauth2_scheme)):
|
|
return {"token": token}
|