cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

The Hub is now in read-only mode as we make improvements to the Hub experience. More information is available here.

Bad Request on refresh token

Marcel-Jan
Shkhara

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?

8 REPLIES 8

livb
Shkhara

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

kgajera
Mt. Kenya

I ran into a similar issue too. I fixed it by passing the following request header: "Content-Type": "application/json"

thank you

Marcel-Jan
Shkhara

So is there no solution? That would really suck. I was so happy with my dashboard.

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'}]}

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']

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.

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?