hermes.commands.init.util.oauth_process
=======================================

.. py:module:: hermes.commands.init.util.oauth_process


Attributes
----------

.. autoapisummary::

   hermes.commands.init.util.oauth_process.PREFER_DEVICE_FLOW
   hermes.commands.init.util.oauth_process.DEACTIVATE_BROWSER_OPENING


Classes
-------

.. autoapisummary::

   hermes.commands.init.util.oauth_process.OauthProcess
   hermes.commands.init.util.oauth_process.Handler


Functions
---------

.. autoapisummary::

   hermes.commands.init.util.oauth_process.setup_logging_for_oauthlib
   hermes.commands.init.util.oauth_process.parse_response_to_dict
   hermes.commands.init.util.oauth_process.extract_value


Module Contents
---------------

.. py:data:: PREFER_DEVICE_FLOW
   :value: True


.. py:data:: DEACTIVATE_BROWSER_OPENING
   :value: False


.. py:function:: setup_logging_for_oauthlib()

   This makes requests_oauthlib.oauth2_session print all the debug logs onto the console.
   It only works if the hermes logger is deactivated.


.. py:function:: parse_response_to_dict(response_text: str) -> dict

   Tries to read the response_text as Json-String to return it as dict.
   If that fails, it tries to read it as query string.


.. py:function:: extract_value(value)

.. py:class:: OauthProcess(name: str, client_id: str = '', client_secret: str = '', authorize_url: str = '', token_url: str = '', scope: str = '', local_port: int = 5333, device_code_url: str = '')

   .. py:attribute:: name


   .. py:attribute:: local_port
      :value: 5333



   .. py:attribute:: scope
      :value: ''



   .. py:attribute:: client_id
      :value: ''



   .. py:attribute:: client_secret
      :value: ''



   .. py:attribute:: authorize_url
      :value: ''



   .. py:attribute:: token_url
      :value: ''



   .. py:attribute:: redirect_uri
      :value: 'http://localhost:/callback'



   .. py:attribute:: shutdown_event


   .. py:attribute:: tokens


   .. py:attribute:: device_code_url
      :value: ''



   .. py:attribute:: server
      :type:  http.server.HTTPServer
      :value: None



   .. py:attribute:: error_description
      :type:  str
      :value: ''



   .. py:method:: create_handler_constructor()


   .. py:method:: start_server(port: int = None)


   .. py:method:: kill_server()


   .. py:method:: open_browser(port: int = None) -> bool


   .. py:method:: get_tokens_from_refresh_token(refresh_token: str) -> dict[str:str]

      Returns access and refresh token as dict using a refresh token



   .. py:method:: get_tokens_from_auth_code(auth_code: str) -> dict[str:str]

      Returns access and refresh token as dict using an auth-code



   .. py:method:: get_tokens_from_device_flow() -> dict[str:str]


   .. py:method:: get_tokens_from_oauth() -> dict[str:str]


   .. py:method:: get_tokens() -> dict[str:str]


.. py:class:: Handler(*args, oauth_process: OauthProcess = None, **kwargs)

   Bases: :py:obj:`http.server.BaseHTTPRequestHandler`


   Simple implementation of BaseHTTPRequestHandler for getting oauth responses


   .. py:attribute:: oauth_process
      :value: None



   .. py:method:: do_GET()


   .. py:method:: index()


   .. py:method:: callback()


   .. py:method:: log_request(code='-', size='-')

      Log an accepted request.

      This is called by send_response().




