FastAPI - Authentication and Security
What is wrong with this FastAPI OAuth2 password flow code snippet?
from fastapi import FastAPI, Depends
from fastapi.security import OAuth2PasswordRequestForm
app = FastAPI()
@app.post('/token')
async def login(form_data: OAuth2PasswordRequestForm):
if form_data.username == 'bob' and form_data.password == 'pass':
return {'access_token': 'abc', 'token_type': 'bearer'}
return {'error': 'Invalid'}