Spaces:
Runtime error
Runtime error
Update google_function.py
Browse files- google_function.py +4 -2
google_function.py
CHANGED
@@ -140,11 +140,12 @@ def local_storage_set(key, value):
|
|
140 |
return st_javascript(f"localStorage.setItem('{key}', '{value}');")
|
141 |
|
142 |
def connetti_google():
|
|
|
143 |
load_dotenv()
|
144 |
json_variable_str = os.getenv("JSON_GOOGLE")
|
145 |
with open("./credentials.json", "w") as f:
|
146 |
f.write(json_variable_str)
|
147 |
-
flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES, redirect_uri=
|
148 |
token = local_storage_get("token")
|
149 |
print('------------1------------------')
|
150 |
print(token)
|
@@ -161,7 +162,8 @@ def connetti_google():
|
|
161 |
auth_code = st.query_params.get("code")
|
162 |
if auth_code:
|
163 |
local_storage_set("token", auth_code)
|
164 |
-
|
|
|
165 |
else:
|
166 |
print('------------4------------------')
|
167 |
st.write("")
|
|
|
140 |
return st_javascript(f"localStorage.setItem('{key}', '{value}');")
|
141 |
|
142 |
def connetti_google():
|
143 |
+
redirect = 'https://matteoscript-streamlitchat-new.hf.space'
|
144 |
load_dotenv()
|
145 |
json_variable_str = os.getenv("JSON_GOOGLE")
|
146 |
with open("./credentials.json", "w") as f:
|
147 |
f.write(json_variable_str)
|
148 |
+
flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES, redirect_uri=redirect)
|
149 |
token = local_storage_get("token")
|
150 |
print('------------1------------------')
|
151 |
print(token)
|
|
|
162 |
auth_code = st.query_params.get("code")
|
163 |
if auth_code:
|
164 |
local_storage_set("token", auth_code)
|
165 |
+
nav_script = """<meta http-equiv="refresh" content="0; url='%s'">""" % (redirect)
|
166 |
+
st.write(nav_script, unsafe_allow_html=True)
|
167 |
else:
|
168 |
print('------------4------------------')
|
169 |
st.write("")
|