Skip to content
Discussion options

You must be logged in to vote

This works fine at least in current version (0.115.13).
get_current_user (and its sub-dependencies) will be called twice with different scopes.

from typing import Annotated

from fastapi import APIRouter, Depends, FastAPI, Security
from fastapi.security import OAuth2PasswordBearer, SecurityScopes
from fastapi.testclient import TestClient

oauth2_scheme = OAuth2PasswordBearer(
    tokenUrl="token",
    scopes={"blog:read": "Read information.", "blog:admin": "Full access."},
)


async def get_token_validated_parsed(
    scopes: SecurityScopes, token: Annotated[str, Depends(oauth2_scheme)]
):
    print("get_token_validated_parsed is called with scopes:", scopes.scopes)
    return token


async 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants