cancel
Showing results for 
Search instead for 
Did you mean: 

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?

3 REPLIES 3

kgajera
Mt. Kenya

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

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