Skip to content

Commit

Permalink
fix: Add timeout to run_local_server when waiting for response (#245)
Browse files Browse the repository at this point in the history
* fix:Add timeout to run_local_server when waiting for response
  • Loading branch information
wonggw authored Oct 20, 2022
1 parent 8c29d2e commit 8d53bc3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions google_auth_oauthlib/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def run_local_server(
success_message=_DEFAULT_WEB_SUCCESS_MESSAGE,
open_browser=True,
redirect_uri_trailing_slash=True,
timeout_seconds=None,
**kwargs
):
"""Run the flow using the server strategy.
Expand Down Expand Up @@ -478,6 +479,10 @@ def run_local_server(
in the user's browser.
redirect_uri_trailing_slash (bool): whether or not to add trailing
slash when constructing the redirect_uri. Default value is True.
timeout_seconds (int): It will raise an error after the timeout timing
if there are no credentials response. The value is in seconds.
When set to None there is no timeout.
Default value is None.
kwargs: Additional keyword arguments passed through to
:meth:`authorization_url`.
Expand All @@ -503,6 +508,7 @@ def run_local_server(

print(authorization_prompt_message.format(url=auth_url))

local_server.timeout = timeout_seconds
local_server.handle_request()

# Note: using https here because oauthlib is very picky that
Expand Down

0 comments on commit 8d53bc3

Please sign in to comment.