Fix `scopes` -> `oauth_scopes`

This commit is contained in:
Yurii Motov 2026-01-08 15:10:58 +01:00
parent ff9778d92b
commit ca186edcf3
2 changed files with 5 additions and 5 deletions

View File

@ -29,20 +29,20 @@ async def root():
@app.get(
"/with-oauth2-scheme",
dependencies=[Security(oauth2_scheme, scopes=["read", "write"])],
dependencies=[Security(oauth2_scheme, oauth_scopes=["read", "write"])],
)
async def read_with_oauth2_scheme():
return {"message": "Admin Access"}
@app.get(
"/with-get-token", dependencies=[Security(get_token, scopes=["read", "write"])]
"/with-get-token", dependencies=[Security(get_token, oauth_scopes=["read", "write"])]
)
async def read_with_get_token():
return {"message": "Admin Access"}
router = APIRouter(dependencies=[Security(oauth2_scheme, scopes=["read"])])
router = APIRouter(dependencies=[Security(oauth2_scheme, oauth_scopes=["read"])])
@router.get("/items/")
@ -52,7 +52,7 @@ async def read_items(token: Optional[str] = Depends(oauth2_scheme)):
@router.post("/items/")
async def create_item(
token: Optional[str] = Security(oauth2_scheme, scopes=["read", "write"]),
token: Optional[str] = Security(oauth2_scheme, oauth_scopes=["read", "write"]),
):
return {"token": token}

View File

@ -21,7 +21,7 @@ async def get_token(token: Annotated[str, Depends(oauth2_scheme)]) -> str:
app = FastAPI(dependencies=[Depends(get_token)])
@app.get("/admin", dependencies=[Security(get_token, scopes=["read", "write"])])
@app.get("/admin", dependencies=[Security(get_token, oauth_scopes=["read", "write"])])
async def read_admin():
return {"message": "Admin Access"}