MCPcopy
hub / github.com/fastapi/fastapi / login

Function login

docs_src/security/tutorial003_an_py310.py:78–87  ·  view source on GitHub ↗
(form_data: Annotated[OAuth2PasswordRequestForm, Depends()])

Source from the content-addressed store, hash-verified

76
77@app.post("/token")
78async def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):
79 user_dict = fake_users_db.get(form_data.username)
80 if not user_dict:
81 raise HTTPException(status_code=400, detail="Incorrect username or password")
82 user = UserInDB(**user_dict)
83 hashed_password = fake_hash_password(form_data.password)
84 if not hashed_password == user.hashed_password:
85 raise HTTPException(status_code=400, detail="Incorrect username or password")
86
87 return {"access_token": user.username, "token_type": "bearer"}
88
89
90@app.get("/users/me")

Callers

nothing calls this directly

Calls 5

DependsClass · 0.90
HTTPExceptionClass · 0.90
UserInDBClass · 0.70
fake_hash_passwordFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…