mirror of https://github.com/tiangolo/fastapi.git
Fix `scopes` -> `oauth_scopes`
This commit is contained in:
parent
ff9778d92b
commit
ca186edcf3
|
|
@ -29,20 +29,20 @@ async def root():
|
||||||
|
|
||||||
@app.get(
|
@app.get(
|
||||||
"/with-oauth2-scheme",
|
"/with-oauth2-scheme",
|
||||||
dependencies=[Security(oauth2_scheme, scopes=["read", "write"])],
|
dependencies=[Security(oauth2_scheme, oauth_scopes=["read", "write"])],
|
||||||
)
|
)
|
||||||
async def read_with_oauth2_scheme():
|
async def read_with_oauth2_scheme():
|
||||||
return {"message": "Admin Access"}
|
return {"message": "Admin Access"}
|
||||||
|
|
||||||
|
|
||||||
@app.get(
|
@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():
|
async def read_with_get_token():
|
||||||
return {"message": "Admin Access"}
|
return {"message": "Admin Access"}
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter(dependencies=[Security(oauth2_scheme, scopes=["read"])])
|
router = APIRouter(dependencies=[Security(oauth2_scheme, oauth_scopes=["read"])])
|
||||||
|
|
||||||
|
|
||||||
@router.get("/items/")
|
@router.get("/items/")
|
||||||
|
|
@ -52,7 +52,7 @@ async def read_items(token: Optional[str] = Depends(oauth2_scheme)):
|
||||||
|
|
||||||
@router.post("/items/")
|
@router.post("/items/")
|
||||||
async def create_item(
|
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}
|
return {"token": token}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ async def get_token(token: Annotated[str, Depends(oauth2_scheme)]) -> str:
|
||||||
app = FastAPI(dependencies=[Depends(get_token)])
|
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():
|
async def read_admin():
|
||||||
return {"message": "Admin Access"}
|
return {"message": "Admin Access"}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue