Update app.py
Browse files
app.py
CHANGED
|
@@ -47,53 +47,6 @@ if OPENROUTER_API_KEY:
|
|
| 47 |
st.error(f"❌ Error during LLM client initialization: {e}")
|
| 48 |
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# def authenticate_service():
|
| 53 |
-
# creds = None
|
| 54 |
-
# if 'google_creds' in st.session_state:
|
| 55 |
-
# return st.session_state.google_creds
|
| 56 |
-
|
| 57 |
-
# if os.path.exists(TOKEN_FILE):
|
| 58 |
-
# creds = Credentials.from_authorized_user_file(TOKEN_FILE, ALL_SCOPES)
|
| 59 |
-
|
| 60 |
-
# if not creds or not creds.valid:
|
| 61 |
-
# if creds and creds.expired and creds.refresh_token:
|
| 62 |
-
# creds.refresh(Request())
|
| 63 |
-
# else:
|
| 64 |
-
# client_config = json.loads(os.environ.get("GCP_CREDENTIALS"))
|
| 65 |
-
|
| 66 |
-
# # --- THE FIX: Use the exact URI registered in Google Console ---
|
| 67 |
-
# # Make sure this has the trailing slash /
|
| 68 |
-
# redirect_uri = "https://alakbarli-assistant.hf.space/"
|
| 69 |
-
|
| 70 |
-
# flow = InstalledAppFlow.from_client_config(
|
| 71 |
-
# client_config,
|
| 72 |
-
# scopes=ALL_SCOPES,
|
| 73 |
-
# redirect_uri=redirect_uri
|
| 74 |
-
# )
|
| 75 |
-
|
| 76 |
-
# query_params = st.query_params
|
| 77 |
-
# if "code" in query_params:
|
| 78 |
-
# # Use the SAME redirect_uri here
|
| 79 |
-
# flow.fetch_token(code=query_params["code"])
|
| 80 |
-
# creds = flow.credentials
|
| 81 |
-
# st.session_state.google_creds = creds
|
| 82 |
-
# st.query_params.clear()
|
| 83 |
-
# with open(TOKEN_FILE, "w") as token:
|
| 84 |
-
# token.write(creds.to_json())
|
| 85 |
-
# st.rerun()
|
| 86 |
-
# else:
|
| 87 |
-
# # And the SAME redirect_uri here
|
| 88 |
-
# auth_url, _ = flow.authorization_url(prompt='consent', access_type='offline')
|
| 89 |
-
# st.info("⚠️ Access Restricted: Please sign in to your Google Account.")
|
| 90 |
-
# st.link_button("🔑 Login with Google", auth_url)
|
| 91 |
-
# return None
|
| 92 |
-
|
| 93 |
-
# st.session_state.google_creds = creds
|
| 94 |
-
# return creds
|
| 95 |
-
|
| 96 |
-
|
| 97 |
def authenticate_service():
|
| 98 |
# 1. ONLY check the current user's session memory
|
| 99 |
if 'google_creds' in st.session_state:
|
|
|
|
| 47 |
st.error(f"❌ Error during LLM client initialization: {e}")
|
| 48 |
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
def authenticate_service():
|
| 51 |
# 1. ONLY check the current user's session memory
|
| 52 |
if 'google_creds' in st.session_state:
|