Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 4f0b8f5

Browse files
committed
Updates to GetAuthCodeServer
Fix #29
1 parent a649bec commit 4f0b8f5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/onedrivesdk/helpers/GetAuthCodeServer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,23 @@ def get_auth_code(auth_url, redirect_uri):
4141
and stuff. Does block main thread.
4242
4343
Args:
44-
auth_url (str): URL of auth server
44+
auth_url (str): URL of auth server.
4545
redirect_uri (str): Redirect URI, as set for the app. Should be
4646
something like "http://localhost:8080" for this to work.
4747
4848
Returns:
4949
str: A string representing the auth code, sent back by the server
5050
"""
51-
HOST, PORT = urlparse(redirect_uri).netloc.split(':')
52-
PORT = int(PORT)
51+
url_netloc = urlparse(redirect_uri).netloc
52+
if ':' not in url_netloc:
53+
host_address = url_netloc
54+
port = 80 # default port
55+
else:
56+
host_address, port = url_netloc.split(':')
57+
port = int(port)
5358
# Set up HTTP server and thread
5459
code_acquired = threading.Event()
55-
s = GetAuthCodeServer((HOST, PORT), code_acquired, GetAuthCodeRequestHandler)
60+
s = GetAuthCodeServer((host_address, port), code_acquired, GetAuthCodeRequestHandler)
5661
th = threading.Thread(target=s.serve_forever)
5762
th.start()
5863
webbrowser.open(auth_url)

src/onedrivesdk/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.4
1+
1.0.6

0 commit comments

Comments
 (0)