get_current_user() — fastapi Function Reference
Architecture documentation for the get_current_user() function in tutorial004_py310.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 30b41bed_6f93_9060_72c6_a2ab6f3903f0["get_current_user()"] 94431617_6d9c_db53_7d48_f9b8408147c2["tutorial004_py310.py"] 30b41bed_6f93_9060_72c6_a2ab6f3903f0 -->|defined in| 94431617_6d9c_db53_7d48_f9b8408147c2 b3f7c06a_afa7_8b3c_a80b_7b3a60296bf4["get_user()"] 30b41bed_6f93_9060_72c6_a2ab6f3903f0 -->|calls| b3f7c06a_afa7_8b3c_a80b_7b3a60296bf4 style 30b41bed_6f93_9060_72c6_a2ab6f3903f0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
docs_src/security/tutorial004_py310.py lines 89–106
async def get_current_user(token: str = Depends(oauth2_scheme)):
credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
headers={"WWW-Authenticate": "Bearer"},
)
try:
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
username = payload.get("sub")
if username is None:
raise credentials_exception
token_data = TokenData(username=username)
except InvalidTokenError:
raise credentials_exception
user = get_user(fake_users_db, username=token_data.username)
if user is None:
raise credentials_exception
return user
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does get_current_user() do?
get_current_user() is a function in the fastapi codebase, defined in docs_src/security/tutorial004_py310.py.
Where is get_current_user() defined?
get_current_user() is defined in docs_src/security/tutorial004_py310.py at line 89.
What does get_current_user() call?
get_current_user() calls 1 function(s): get_user.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free