code: def login_with_browser(self, auth: Auth) -> None:
      app = FastAPI()
      port = find_free_network_port()
      url = self.get_auth_url(port)
  
      try:
          # check if server is reachable or catch any network errors
          requests.head(url)
      except requests.ConnectionError as ex:
          raise requests.ConnectionError(
              f"No internet connection available. Please connect to a stable internet connection \n{ex}"  # E501
          )
      except requests.RequestException as ex:
          raise requests.RequestException(
              f"An error occurred with the request. Please report this issue to Lightning Team \n{ex}"  # E501
          )
  
      logger.info(
          "\nAttempting to automatically open the login page in your default browser.\n"
          'If the browser does not open, navigate to the "Keys" tab on your Lightning AI profile page:\n\n'
          f"{get_lightning_cloud_url()}/me/keys\n\n"
          'Copy the "Headless CLI Login" command, and execute it in your terminal.\n'
      )
      click.launch(url)
  
      @app.get("/login-complete")
      async def save_token(
          request: Request,
          token="",
          key="",
          user_id: str = Query("", alias="userID"),
      ):
          async def stop_server_once_request_is_done():
              while not await request.is_disconnected():
                  sleep(0.25)
              server.should_exit = True
  
          if not token:
              logger.warn(
                  "Login Failed. This is most likely because you're using an older version of the CLI. \n"  # noqa E501
                  "Please try to update the CLI or open an issue with this information \n"  # E501
                  f"expected token in {request.query_params.items()}"
              )
              return RedirectResponse(
                  url=f"{get_lightning_cloud_url()}/cli-login-failed",
                  background=BackgroundTask(
                      stop_server_once_request_is_done
                  ),
              )
  
          auth.save(
              token=token,
              username=user_id,
              user_id=user_id,
              api_key=key,
          )
          logger.info("Login Successful")
  
          # Include the credentials in the redirect so that UI will also be logged in
          params = urlencode(
              {"token": token, "key": key, "userID": user_id}
          )
  
          return RedirectResponse(
              url=f"{get_lightning_cloud_url()}/cli-login-successful?{params}",
              background=BackgroundTask(
                  stop_server_once_request_is_done
              ),
          )
  
      server = uvicorn.Server(
          config=uvicorn.Config(app, port=port, log_level="error")
      )
      server.run()
  
imports: import base64
  import json
  import os
  import pathlib
  from dataclasses import dataclass
  from enum import Enum
  from time import sleep
  from typing import Optional
  from urllib.parse import urlencode
  import click
  import requests
  import uvicorn
  from fastapi import FastAPI, Query, Request
  from starlette.background import BackgroundTask
  from starlette.responses import RedirectResponse
  from lightning.app.core.constants import LIGHTNING_CREDENTIAL_PATH, get_lightning_cloud_url
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.network import find_free_network_port
label_desc: Use image node_id 2 for calling the AuthServer obj's underlying member method code with example usage: obj.login_with_browser(auth) and returns: RedirectResponse, RedirectResponse