Spaces:
Sleeping
Sleeping
Update google_function.py
Browse files- google_function.py +8 -3
google_function.py
CHANGED
@@ -135,16 +135,21 @@ def leggi_calendario_google(max_results=10):
|
|
135 |
def connetti_google():
|
136 |
load_dotenv()
|
137 |
json_variable_str = os.getenv("JSON_GOOGLE")
|
138 |
-
|
|
|
139 |
f.write(json_variable_str)
|
|
|
|
|
|
|
|
|
140 |
creds = None
|
141 |
-
if os.path.exists("token.json"):
|
142 |
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
|
143 |
if not creds or not creds.valid:
|
144 |
if creds and creds.expired and creds.refresh_token:
|
145 |
creds.refresh(Request())
|
146 |
else:
|
147 |
-
flow = InstalledAppFlow.from_client_secrets_file("credentials.json", SCOPES)
|
148 |
creds = flow.run_local_server(port=0)
|
149 |
with open("token.json", "w") as token:
|
150 |
token.write(creds.to_json())
|
|
|
135 |
def connetti_google():
|
136 |
load_dotenv()
|
137 |
json_variable_str = os.getenv("JSON_GOOGLE")
|
138 |
+
print(json_variable_str)
|
139 |
+
with open("./credentials.json", "w") as f:
|
140 |
f.write(json_variable_str)
|
141 |
+
if os.path.exists("./credentials.json"):
|
142 |
+
print('ESISTE')
|
143 |
+
else:
|
144 |
+
print('NON ESISTE')
|
145 |
creds = None
|
146 |
+
if os.path.exists("./token.json"):
|
147 |
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
|
148 |
if not creds or not creds.valid:
|
149 |
if creds and creds.expired and creds.refresh_token:
|
150 |
creds.refresh(Request())
|
151 |
else:
|
152 |
+
flow = InstalledAppFlow.from_client_secrets_file("./credentials.json", SCOPES)
|
153 |
creds = flow.run_local_server(port=0)
|
154 |
with open("token.json", "w") as token:
|
155 |
token.write(creds.to_json())
|