Beispiel #1
0
def get_auth_code(hostname='localhost', port=8080, listen_path='/'):
    """Listens for an incoming auth code redirect

    This will probably need to be called in a thread so that an initial request
    can be sent while the redirect listener is listening.

    Args:
        hostname (str, optional): The hostname to listen on.
        port (int, optional): What port to listen on
        listen_path (str, optional): What path to listen on"""

    httpd = TCPServer((hostname, port), AuthCodeListener)
    while httpd.RequestHandlerClass.keep_listening:
        httpd.handle_request()

    return httpd.RequestHandlerClass.code