Skip to content

Commit

Permalink
Use actual server port in redirect_uri to allow automatic assignment (#…
Browse files Browse the repository at this point in the history
…33)

* Use actual server port in redirect_uri. Allows setting port to 0 to request an unassigned ephemeral port

* Reformat to match linter rules
  • Loading branch information
sqrrrl authored and busunkim96 committed May 9, 2019
1 parent ba82656 commit c547be6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions google_auth_oauthlib/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,14 @@ def run_local_server(
google.oauth2.credentials.Credentials: The OAuth 2.0 credentials
for the user.
"""
self.redirect_uri = 'http://{}:{}/'.format(host, port)

auth_url, _ = self.authorization_url(**kwargs)

wsgi_app = _RedirectWSGIApp(success_message)
local_server = wsgiref.simple_server.make_server(
host, port, wsgi_app, handler_class=_WSGIRequestHandler)

self.redirect_uri = 'http://{}:{}/'.format(
host, local_server.server_port)
auth_url, _ = self.authorization_url(**kwargs)

if open_browser:
webbrowser.open(auth_url, new=1, autoraise=True)

Expand Down

0 comments on commit c547be6

Please sign in to comment.