code: def _add_mocked_oauth_routes(app: fastapi.FastAPI) -> None:
      """Add fake oauth routes if Gradio is run locally and OAuth is enabled.
  
      Clicking on a gr.LoginButton will have the same behavior as in a Space (i.e. gets redirected in a new tab) but
      instead of authenticating with HF, a mocked user profile is added to the session.
      """
      warnings.warn(
          "Gradio does not support OAuth features outside of a Space environment. To help"
          " you debug your app locally, the login and logout buttons are mocked with your"
          " profile. To make it work, your machine must be logged in to Huggingface."
      )
      mocked_oauth_info = _get_mocked_oauth_info()
  
      # Define OAuth routes
      @app.get("/login/huggingface")
      async def oauth_login(request: fastapi.Request):
          """Fake endpoint that redirects to HF OAuth page."""
          return RedirectResponse("/login/callback")
  
      @app.get("/login/callback")
      async def oauth_redirect_callback(
          request: fastapi.Request,
      ) -> RedirectResponse:
          """Endpoint that handles the OAuth callback."""
          request.session["oauth_info"] = mocked_oauth_info
          return RedirectResponse("/")
  
      @app.get("/logout")
      async def oauth_logout(
          request: fastapi.Request,
      ) -> RedirectResponse:
          """Endpoint that logs out the user (e.g. delete cookie session)."""
          request.session.pop("oauth_info", None)
          return RedirectResponse("/")
  
file_path: gradio/gradio/oauth.py
imports: from __future__ import annotations
  import hashlib
  import os
  import typing
  import warnings
  from dataclasses import dataclass, field
  import fastapi
  from fastapi.responses import RedirectResponse
  from huggingface_hub import HfFolder, whoami
  from .utils import get_space
label_desc: Use image node_id 3 for calling a global function with example usage: _add_mocked_oauth_routes(app) and returns: RedirectResponse, RedirectResponse, RedirectResponse