Alakbarli commited on
Commit
5848ed4
·
verified ·
1 Parent(s): 96e528a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -56
app.py CHANGED
@@ -55,62 +55,6 @@ from google.oauth2.credentials import Credentials
55
  cookie_manager = st_tags.CookieManager()
56
 
57
 
58
- # def authenticate_service():
59
- # """Handles persistent Google OAuth2 flow using Browser Cookies with loading wait."""
60
-
61
- # # 1. First, check if it's already in the temporary session
62
- # if 'google_creds' in st.session_state:
63
- # return st.session_state.google_creds
64
-
65
- # # 2. If not in session, wait a moment for the Cookie Manager to load
66
- # # This is the "secret sauce" to prevent login prompts on refresh
67
- # with st.spinner("Restoring session..."):
68
- # time.sleep(0.9) # Small delay for the JS component to sync
69
- # cookie_token = cookie_manager.get(cookie="google_creds_token")
70
-
71
- # # 3. If cookie found, restore it to session
72
- # if cookie_token:
73
- # try:
74
- # creds_info = json.loads(cookie_token)
75
- # creds = Credentials.from_authorized_user_info(creds_info, ALL_SCOPES)
76
-
77
- # if creds and creds.expired and creds.refresh_token:
78
- # creds.refresh(Request())
79
- # cookie_manager.set("google_creds_token", creds.to_json(), key="refresh_sync")
80
-
81
- # st.session_state.google_creds = creds
82
- # return creds
83
- # except Exception as e:
84
- # st.error(f"Cookie restoration failed: {e}")
85
-
86
- # # 4. Standard OAuth Flow (Only if no session AND no cookie)
87
- # client_config = json.loads(os.environ.get("GCP_CREDENTIALS"))
88
- # redirect_uri = "https://alakbarli-assistant.hf.space/"
89
-
90
- # flow = InstalledAppFlow.from_client_config(
91
- # client_config,
92
- # scopes=ALL_SCOPES,
93
- # redirect_uri=redirect_uri
94
- # )
95
-
96
- # query_params = st.query_params
97
- # if "code" in query_params:
98
- # flow.fetch_token(code=query_params["code"])
99
- # creds = flow.credentials
100
-
101
- # # SAVE PERMANENTLY
102
- # st.session_state.google_creds = creds
103
- # cookie_manager.set("google_creds_token", creds.to_json(), key="init_save")
104
-
105
- # st.query_params.clear()
106
- # st.rerun()
107
- # else:
108
- # # This is where the login button lives
109
- # auth_url, _ = flow.authorization_url(prompt='consent', access_type='offline')
110
- # st.info("👋 Welcome! Please connect your Google account to continue.")
111
- # st.link_button("🔑 Login with Google", auth_url)
112
- # return None
113
-
114
  def authenticate_service():
115
  cm = st.session_state.cookie_manager
116
 
 
55
  cookie_manager = st_tags.CookieManager()
56
 
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  def authenticate_service():
59
  cm = st.session_state.cookie_manager
60