PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
oauth_server Namespace Reference

Data Structures

class  OAuthHandler
 

Functions

def main ()
 

Function Documentation

◆ main()

def oauth_server.main ( void  )
Starts the authorization server on localhost. The ephemeral port in use will
be printed to stdout.

Definition at line 359 of file oauth_server.py.

359def main():
360 """
361 Starts the authorization server on localhost. The ephemeral port in use will
362 be printed to stdout.
363 """
364
365 s = http.server.HTTPServer(("127.0.0.1", 0), OAuthHandler)
366
367 # Attach a "cache" dictionary to the server to allow the OAuthHandlers to
368 # track state across token requests. The use of defaultdict ensures that new
369 # entries will be created automatically.
370 class _TokenState:
371 retries = 0
372 min_delay = None
373 last_try = None
374
375 s.token_state = defaultdict(_TokenState)
376
377 # Give the parent the port number to contact (this is also the signal that
378 # we're ready to receive requests).
379 port = s.socket.getsockname()[1]
380 print(port)
381
382 # stdout is closed to allow the parent to just "read to the end".
383 stdout = sys.stdout.fileno()
384 sys.stdout.close()
385 os.close(stdout)
386
387 s.serve_forever() # we expect our parent to send a termination signal
388
389
void print(const void *obj)
Definition: print.c:36

References main(), and print().

Referenced by oauth_server.OAuthHandler._token_state(), and main().