mirror of https://github.com/tiangolo/fastapi.git
13 lines
319 B
Python
13 lines
319 B
Python
from fastapi import Depends, FastAPI
|
|
from fastapi.security import OAuth2PasswordBearer
|
|
from typing_extensions import Annotated
|
|
|
|
app = FastAPI()
|
|
|
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(token: Annotated[str, Depends(oauth2_scheme)]):
|
|
return {"token": token}
|