| 1 |
from fastapi import Depends, FastAPI |
| 2 |
from fastapi.security import OAuth2PasswordBearer |
| 3 |
|
| 4 |
app = FastAPI() |
| 5 |
|
| 6 |
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") |
| 7 |
|
| 8 |
|
| 9 |
@app.get("/items/") |
| 10 |
async def read_items(token: str = Depends(oauth2_scheme)): |
| 11 |
return {"token": token} |