Skip to content

Commit

Permalink
log oauth redirect server token handler
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Jan 3, 2025
1 parent 36f981d commit bcb61cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pcloud/oauth2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import logging
import _thread
import time

Expand All @@ -8,6 +9,9 @@
from urllib.parse import urlparse
from webbrowser import open_new

log = logging.getLogger("pcloud")
log.setLevel(logging.INFO)


PORT = 65432
REDIRECT_URL = f"http://localhost:{PORT}/"
Expand Down Expand Up @@ -63,10 +67,12 @@ def get_access_token(self):
def start_server():
http_server.handle_request()

log.info(f"Start token server {PORT}")
_thread.start_new_thread(start_server, ())
self.open_browser()
while not (http_server.access_token and http_server.pc_hostname):
time.sleep(1)
self.close_browser()
http_server.server_close()
log.info(f"Teardown token server {PORT}")
return http_server.access_token, http_server.pc_hostname

0 comments on commit bcb61cf

Please sign in to comment.