@@ -24,7 +24,7 @@ def __init__(self, token_data):
2424 super ().__init__ ("Token received successfully" )
2525
2626
27- def make_request_handler_class (state , code_verifier , token_callback ):
27+ def make_request_handler_class (state , code_verifier , token_callback , domain ):
2828 class SimpleHTTPSRequestHandler (http .server .SimpleHTTPRequestHandler ):
2929 """Simple HTTPS request handler that serves static files."""
3030
@@ -85,6 +85,10 @@ def do_GET(self):
8585 content = content .replace ("__PY_REPLACE_EXPECTED_STATE__" , state )
8686 content = content .replace ("__PY_REPLACE_CODE_VERIFIER__" , code_verifier )
8787 content = content .replace ("__PY_REPLACE_REDIRECT_URI__" , redirect_uri )
88+ content = content .replace (
89+ "__PY_REPLACE_CLIENT_ID__" , auth_config ["client_id" ]
90+ )
91+ content = content .replace ("__PY_REPLACE_DOMAIN__" , domain )
8892
8993 self .send_response (200 )
9094 self .send_header ("Content-Type" , "text/html" )
@@ -123,25 +127,25 @@ def token_received_callback(self, token_data):
123127 self .token_data = token_data
124128 self .should_shutdown = True
125129
126- def create_server (self , state , code_verifier ):
130+ def create_server (self , state , code_verifier , domain ):
127131 """Create and configure the HTTPS server."""
128132 # Create SSL context
129133 context = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
130134 context .load_cert_chain (self .cert_file , self .key_file )
131135
132136 # Create server
133137 handler = make_request_handler_class (
134- state , code_verifier , self .token_received_callback
138+ state , code_verifier , self .token_received_callback , domain
135139 )
136140 self .httpd = socketserver .TCPServer (("" , self .port ), handler )
137141 self .httpd .socket = context .wrap_socket (self .httpd .socket , server_side = True )
138142
139143 return self .httpd
140144
141- def start (self , state , code_verifier ):
145+ def start (self , state , code_verifier , domain ):
142146 """Start the server."""
143147 if not self .httpd :
144- self .create_server (state , code_verifier )
148+ self .create_server (state , code_verifier , domain )
145149
146150 try :
147151 if self .httpd :
0 commit comments