Skip to main content

Yesterday (14/01/2025), I could make requests to the Strava API without any problems. For example, this endpoint was working perfectly for some tests:

https://www.strava.com/api/v3/activities/13181274603

 

But today, despite having a new token that is valid, I am getting the following error:

“””Token expired, refreshing...
Data successfully inserted.
Error making request to https://www.strava.com/api/v3/activities/13181274603: 401 Client Error: Unauthorized for url: https://www.strava.com/api/v3/activities/13181274603”””

 

Is anyone else experiencing this?

This is a piece of my Python code:
“””
 

    def _get_headers(self) -> Dict_str, str]:
"""Generate headers for requests."""
return {
"Authorization": f"Bearer {self.access_token}",
"Content-Type": "application/json",
}

def _get_url(self, endpoint: str) -> str:
"""Construct full URL for a given endpoint."""
return f"{self.BASE_URL}{endpoint}"

def _make_request(self, url: str, params: dict = None) -> dict:
try:
response = requests.get(url, headers=self._get_headers(), params=params)
response.raise_for_status()
return response.json()

except requests.exceptions.RequestException as e:
print(f"Error making request to {url}: {e}")
return {}

def get_one_activity(self) -> dict:
url = self._get_url(f"/activities/{self.id_activity}")
return self._make_request(url)

def get_last_200_activities(self) -> ListtDict]:
"""Fetch the last 200 activities for the authenticated user."""
url = self._get_url("/activities")
params = {"per_page": 200, "page": 1}
return self._make_request(url, params)


“””

Thanks!

It’s solved! One character in the code broke it!

 

Sorry


Reply