Skip to content

Error getting request body: The python-multipart library must be installed to use form parsing. #1551

@q98765543221

Description

@q98765543221

(venv) G:\projects\python\fastprojects>pip list

python-dateutil 2.8.1
python-multipart 0.0.5
rope 0.17.0

@app.post('/token', tags=['safe'])
async def login(form_data: OAuth2PasswordRequestForm = Depends()):
  print('form_data', form_data)
  user_dict = fake_users_db.get(form_data.username)
  if not user_dict:
    raise HTTPException(
      status_code=400,
      detail='Incorrect username or password'
    )
  user = UserInDB(**user_dict)
  hashed_password = fake_hash_password(form_data.password)
  if not hashed_password == user.hashed_password:
    raise HTTPException(
      status_code=400,
      detail='Incorrect username or password'
    )
  return {'access_token': user.username, 'token_type': 'bearer'}

I don't know how to troubleshoot this problem

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions