05-23-2023 07:43 AM - last edited on 07-06-2023 05:05 PM by LouB
I have a Raspberry Pi with an e-ink display that shows my latest cycling stats: kilometers per year, month and a calculated projected total of kilometers for the entire year. Every hour the totals are updated. It has worked well for several months.
Since last week it stopped working. It was about the time that my app was approved, but that might be coincidental. The step that stopped working is the refresh token. I get a Bad Request on this part:
tokens = requests.post(url=f'https://www.strava.com/api/v3/oauth/token' \
f'?client_id={strava_client_id}' \
f'&client_secret={strava_client_secret}' \
f'&grant_type=refresh_token' \
f'&refresh_token={strava_refresh_token}',
timeout=timeout)
I've tried creating a new client secret, successfully retrieved a new access token. And then I was able to retrieve my athlete data and update my dashboard. But every time I try to get a refresh token I keep getting Bad Request.
My complete source code is available on Github: https://github.com/Marcel-Jan/StravaInky
How can I get my dashboard update automatically again? Did the refresh token URL change?
05-19-2024 01:47 AM
Not sure if this will help you too or if the issue has been fixed since Novemeber anyway. But I have now followed the steps in https://medium.com/analytics-vidhya/accessing-user-data-via-the-strava-api-using-stravalib-d5bee7fdd... and am having no more issues with refresh tokens
05-26-2023 06:59 AM
I ran into a similar issue too. I fixed it by passing the following request header: "Content-Type": "application/json"
5 hours ago
thank you
05-26-2023 06:29 AM
So is there no solution? That would really suck. I was so happy with my dashboard.
05-30-2023 03:49 AM
I've added the Content-Type, but still no success.
try:
tokens = requests.post(url=f'https://www.strava.com/api/v3/oauth/token' \
f'?client_id={strava_client_id}' \
f'&client_secret={strava_client_secret}' \
f'&grant_type=refresh_token' \
f'&refresh_token={strava_refresh_token}',
headers={"Content-Type": "application/json"},
timeout=timeout)
Still getting this one:
{'message': 'Bad Request', 'errors': [{'resource': 'RefreshToken', 'field': 'refresh_token', 'code': 'invalid'}]}
11-14-2023 11:41 PM - edited 11-14-2023 11:42 PM
has anyone managed to help you with this? I am having the same issue. My code is:
auth_url = "https://www.strava.com/api/v3/oauth/token"
payload = {
'client_id': strava_client_id,
'client_secret': strava_client_secret,
'grant_type ': "refresh_token",
'refresh_token': activity_refresh_token, #code I was given with the working access token last time I ran the app
"Content-Type": "application/json"
}
activity_access_token = requests.post(auth_url, data=payload).json()['access_token']
11-16-2023 02:11 AM
I never found a solution that worked for this. Even though this is following the documentation. My last attempt to get any response from Strava, was asking them on Twitter. But no response there either.
Too bad. This means my wonderful Strava dashboard on Raspberry Pi will never automatically update again.
11-16-2023 11:26 AM
Oh no that's really sad I was hoping my dash app would work this way! I think I might connect intervals.icu and then use their api instead, maybe that could work for you too?
Welcome to the Community - here is your guide to help you get started!