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 386 of file oauth_server.py.

386def main():
387 """
388 Starts the authorization server on localhost. The ephemeral port in use will
389 be printed to stdout.
390 """
391
392 s = http.server.HTTPServer(("127.0.0.1", 0), OAuthHandler)
393
394 # Attach a "cache" dictionary to the server to allow the OAuthHandlers to
395 # track state across token requests. The use of defaultdict ensures that new
396 # entries will be created automatically.
397 class _TokenState:
398 retries = 0
399 min_delay = None
400 last_try = None
401
402 s.token_state = defaultdict(_TokenState)
403
404 # Give the parent the port number to contact (this is also the signal that
405 # we're ready to receive requests).
406 port = s.socket.getsockname()[1]
407 print(port)
408
409 # stdout is closed to allow the parent to just "read to the end".
410 stdout = sys.stdout.fileno()
411 sys.stdout.close()
412 os.close(stdout)
413
414 s.serve_forever() # we expect our parent to send a termination signal
415
416
void print(const void *obj)
Definition: print.c:36

References main(), and print().

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