code: def do_local_server_auth_flow(session_params=None, force_new_client=False):
      
      session_params = session_params or {}
  
      # start local server and create matching redirect_uri
      with start_local_server(listen=("127.0.0.1", 0)) as server:
          _, port = server.socket.getsockname()
          redirect_uri = "http://localhost:{}".format(port)
  
          # get the ConfidentialApp client object and start a flow
          auth_client = internal_auth_client(
              requires_instance=True, force_new_client=force_new_client
          )
          auth_client.oauth2_start_flow(
              refresh_tokens=True, redirect_uri=redirect_uri, requested_scopes=SCOPES
          )
          additional_params = {"prompt": "login"}
          additional_params.update(session_params)
          url = auth_client.oauth2_get_authorize_url(additional_params=additional_params)
  
          # open web-browser for user to log in, get auth code
          webbrowser.open(url, new=1)
          auth_code = server.wait_for_code()
  
      if isinstance(auth_code, LocalServerError):
          safeprint("Authorization failed: {}".format(auth_code), write_to_stderr=True)
          click.get_current_context().exit(1)
      elif isinstance(auth_code, Exception):
          safeprint(
              "Authorization failed with unexpected error:\n{}".format(auth_code),
              write_to_stderr=True,
          )
          click.get_current_context().exit(1)
  
      # finish auth flow and return true
      exchange_code_and_store_config(auth_client, auth_code)
      return True
docs: Starts a local http server, opens a browser to have the user authenticate,
      and gets the code redirected to the server (no copy and pasting required)