title: Authentication dependency injection with password users and Google users
body: <p>I am creating an app that allows users to either login with a username and password, or through Google authentication. I have signup and login working for both flows.  This is done by creating two separate login (and signup) endpoints for password and Google users.</p>
  <p>I am now working on using dependency injection to allow users to request various endpoints which will decode their JWT and return the data if they are authenticated, as shown here: <a href="https://fastapi.tiangolo.com/tutorial/security/get-current-user/" rel="nofollow noreferrer">https://fastapi.tiangolo.com/tutorial/security/get-current-user/</a></p>
  <p>This works fine for users that have logged in with a username and password, since this dependency uses <code>OAuth2PasswordBearer</code>.</p>
  <p>However, this of course does not work with my Google users since</p>
  <ol>
  <li>They don't have a password</li>
  <li>The <code>tokenUrl</code> parameter for <code>OAuth2PasswordBearer</code> is set to my password users' login endpoint.</li>
  </ol>
  <p>How can I achieve a <code>get_logged_in_user(token: str = Depends(oauth2_scheme))</code> function that words both for users who have logged in with a password and those who have logged in through Google?</p>