title: FastAPI OAuth2PasswordRequestForm dependency causing request failure
body: <p>I'm using the auth scheme detailed in FastAPI's <a href="https://fastapi.tiangolo.com/tutorial/security/oauth2-jwt/#update-the-token-path-operation" rel="noreferrer">user guide</a> (JWT/Bearer token). When I try to get a token from the <code>/token</code> endpoint the request fails before the path operation function ever runs. Here's the function in question:</p>
  <pre><code>async def login_for_access_token(form_data: OAuth2PasswordRequestForm = Depends(), session: SessionLocal = Depends(get_db)):
      user = authenticate_user(session, form_data.username, form_data.password)
      if not user:
          raise HTTPException(
              status_code=status.HTTP_401_UNAUTHORIZED,
              detail=&quot;Incorrect username or password&quot;,
              headers={&quot;WWW-Authenticate&quot;: &quot;Bearer&quot;},
          )
      access_token = create_access_token(data={&quot;sub&quot;: user.id})
      return {&quot;access_token&quot;: access_token, &quot;token_type&quot;: &quot;bearer&quot;}
  </code></pre>
  <p>I normally use breakpoints to help figure out what's going wrong in these situations, but the call fails before any code in the function actually runs, leading me to believe the problem is with the <code>OAuth2PasswordRequestForm</code> dependency. I verified that this was the problem by disabling the <code>form_data parameter</code> and was able to execute the full request.</p>
  <p>The errors I'm getting are pretty sparse on details. Here's what I'm getting in the console: <code>INFO:     127.0.0.1:52261 - &quot;POST /token HTTP/1.1&quot; 400 Bad Request</code></p>
  <p>And here's what I see in the Swagger UI:</p>
  <p><a href="https://i.stack.imgur.com/t849h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/t849h.png" alt="enter image description here" /></a></p>
  <p>This was working for me in the single-file format used in the tutorial, but I've since broken things out into different files to keep my larger project organized. I have a feeling that I just missed something somewhere along the line while reorganizing this code but can't seem to figure out what is causing this.</p>