Skip to content

Commit a5dc1d9

Browse files
authored
add bind_addr parameter to LocalWebserverAuth (#279)
1 parent 77e4b65 commit a5dc1d9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pydrive2/auth.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ def access_token_expired(self):
212212

213213
@CheckAuth
214214
def LocalWebserverAuth(
215-
self, host_name="localhost", port_numbers=None, launch_browser=True
215+
self,
216+
host_name="localhost",
217+
port_numbers=None,
218+
launch_browser=True,
219+
bind_addr=None,
216220
):
217221
"""Authenticate and authorize from user by creating local web server and
218222
retrieving authentication code.
@@ -226,6 +230,10 @@ def LocalWebserverAuth(
226230
:type port_numbers: list.
227231
:param launch_browser: should browser be launched automatically
228232
:type launch_browser: bool
233+
:param bind_addr: optional IP address for the local web server to listen on.
234+
If not specified, it will listen on the address specified in the
235+
host_name parameter.
236+
:type bind_addr: str.
229237
:returns: str -- code returned from local web server
230238
:raises: AuthenticationRejected, AuthenticationError
231239
"""
@@ -241,7 +249,7 @@ def LocalWebserverAuth(
241249
port_number = port
242250
try:
243251
httpd = ClientRedirectServer(
244-
(host_name, port), ClientRedirectHandler
252+
(bind_addr or host_name, port), ClientRedirectHandler
245253
)
246254
except OSError:
247255
pass

0 commit comments

Comments
 (0)