From 34c859ea23ef202ec878fe512e0f7d570093a3ac Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Sat, 21 Oct 2023 20:05:43 +0800 Subject: [PATCH] fix: bring old logic back --- run_page/nike_sync.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/run_page/nike_sync.py b/run_page/nike_sync.py index 6de51923bc1..d2adfbd34ab 100644 --- a/run_page/nike_sync.py +++ b/run_page/nike_sync.py @@ -31,20 +31,19 @@ class Nike: def __init__(self, refresh_token): self.client = httpx.Client() - # response = self.client.post( - # TOKEN_REFRESH_URL, - # json={ - # "refresh_token": refresh_token, - # "client_id": NIKE_CLIENT_ID, - # "grant_type": "refresh_token", - # }, - # timeout=60, - # ) - # response.raise_for_status() - - # access_token = response.json()["access_token"] - # self.client.headers.update({"Authorization": f"Bearer {access_token}"}) - self.client.headers.update({"Authorization": f"Bearer {refresh_token}"}) + response = self.client.post( + TOKEN_REFRESH_URL, + json={ + "refresh_token": refresh_token, + "client_id": NIKE_CLIENT_ID, + "grant_type": "refresh_token", + }, + timeout=60, + ) + response.raise_for_status() + + access_token = response.json()["access_token"] + self.client.headers.update({"Authorization": f"Bearer {access_token}"}) def get_activities_since_timestamp(self, timestamp): return self.request("activities/after_time", timestamp)