aboutsummaryrefslogtreecommitdiffstats
path: root/cloud_mdir_sync/oauth.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloud_mdir_sync/oauth.py')
-rw-r--r--cloud_mdir_sync/oauth.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cloud_mdir_sync/oauth.py b/cloud_mdir_sync/oauth.py
index 0ab30ae..716e7c0 100644
--- a/cloud_mdir_sync/oauth.py
+++ b/cloud_mdir_sync/oauth.py
@@ -4,6 +4,7 @@ import base64
import hashlib
import os
import secrets
+import webbrowser
from abc import abstractmethod
from typing import TYPE_CHECKING, Dict, List, Optional
@@ -59,6 +60,19 @@ class WebServer(object):
redirects back to the localhost server. The final query paremeters
will be returned by this function"""
queue = asyncio.Queue()
+
+ # If this is the first auth to start then automatically launch a
+ # browser, otherwise assume the already running browser will take care
+ # of things
+ if not self.auth_redirs:
+ print(
+ f"Goto {self.url} in a web browser to authenticate (opening browser)"
+ )
+ webbrowser.open(url)
+ else:
+ print(
+ f"Goto {self.url} in a web browser to authenticate (reusing browser)"
+ )
self.auth_redirs[state] = (url, queue, redir_url)
return await queue.get()