Spaces:
Sleeping
Sleeping
Update google_function.py
Browse files138 unmodified lines1391401411421421431441451461471471481491501511521531531541553 unmodified lines15916016116316216316416522 unmodified lines188189190192191192193194138 unmodified lines return st_javascript(f"localStorage.setItem('{key}', '{value}');")
def connetti_google(): redirect = 'https://matteoscript-streamlitchat-new.hf.space' load_dotenv() json_variable_str = os.getenv("JSON_GOOGLE") URL_REDIRECT = os.getenv('URL_REDIRECT') with open("./credentials.json", "w") as f: f.write(json_variable_str) flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES, redirect_uri=redirect) flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES, redirect_uri=URL_REDIRECT) token = local_storage_get("token") print('------------1------------------') print(token) if token and token != '': print('------------2------------------') #local_storage_set("token", '') flow.fetch_token(code=token) st.session_state.creds = flow.credentials print(st.session_state.creds)3 unmodified lines auth_code = st.query_params.get("code") if auth_code: local_storage_set("token", auth_code) time.sleep(2) time.sleep(0.7) print('**************************************************************') print(auth_code) nav_script = """<meta http-equiv="refresh" content="0; url='%s'">""" % (redirect)22 unmodified lines if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES, redirect_uri='https://matteoscript-streamlitchat-new.hf.space') flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES, redirect_uri=URL_REDIRECT) #creds = flow.run_local_server(port=8501, open_browser=False) creds = flow.run_console() with open("token.json", "w") as token:google_function.py+4-5