Skip to content

Add bind_addr parameter to LocalWebserverAuth #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pydrive2/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ def access_token_expired(self):

@CheckAuth
def LocalWebserverAuth(
self, host_name="localhost", port_numbers=None, launch_browser=True
self,
host_name="localhost",
port_numbers=None,
launch_browser=True,
bind_addr=None,
):
"""Authenticate and authorize from user by creating local web server and
retrieving authentication code.
Expand All @@ -226,6 +230,10 @@ def LocalWebserverAuth(
:type port_numbers: list.
:param launch_browser: should browser be launched automatically
:type launch_browser: bool
:param bind_addr: optional IP address for the local web server to listen on.
If not specified, it will listen on the address specified in the
host_name parameter.
:type bind_addr: str.
:returns: str -- code returned from local web server
:raises: AuthenticationRejected, AuthenticationError
"""
Expand All @@ -241,7 +249,7 @@ def LocalWebserverAuth(
port_number = port
try:
httpd = ClientRedirectServer(
(host_name, port), ClientRedirectHandler
(bind_addr or host_name, port), ClientRedirectHandler
)
except OSError:
pass
Expand Down