Update app.py
Browse files
app.py
CHANGED
|
@@ -253,7 +253,7 @@ def get_valid_tokens():
|
|
| 253 |
"client_secret": CLIENT_SECRET
|
| 254 |
}
|
| 255 |
res_data = fetch_token_from_api(payload)
|
| 256 |
-
if res_data:
|
| 257 |
tokens["access_token"] = res_data["accessToken"]
|
| 258 |
tokens["refresh_token"] = res_data["refreshToken"]
|
| 259 |
tokens["updated_at"] = time.time()
|
|
@@ -262,6 +262,8 @@ def get_valid_tokens():
|
|
| 262 |
tokens["account_id"] = str(res_data["accounts"][0]["ctidTraderAccountId"])
|
| 263 |
save_tokens(tokens)
|
| 264 |
return tokens
|
|
|
|
|
|
|
| 265 |
|
| 266 |
# Return existing tokens if still fresh/valid
|
| 267 |
if access_token:
|
|
|
|
| 253 |
"client_secret": CLIENT_SECRET
|
| 254 |
}
|
| 255 |
res_data = fetch_token_from_api(payload)
|
| 256 |
+
if res_data and "accessToken" in res_data:
|
| 257 |
tokens["access_token"] = res_data["accessToken"]
|
| 258 |
tokens["refresh_token"] = res_data["refreshToken"]
|
| 259 |
tokens["updated_at"] = time.time()
|
|
|
|
| 262 |
tokens["account_id"] = str(res_data["accounts"][0]["ctidTraderAccountId"])
|
| 263 |
save_tokens(tokens)
|
| 264 |
return tokens
|
| 265 |
+
else:
|
| 266 |
+
logger.error(f"Failed to refresh token: {res_data}")
|
| 267 |
|
| 268 |
# Return existing tokens if still fresh/valid
|
| 269 |
if access_token:
|