Skip to main content
Answered

API activity request with refresh capability for access token

  • Feb 22, 2023 7:28 PM UTC
  • 4 replies
  • 217 views

Forum|alt.badge.img+6

I am unable to retrieve my activities via my React application, despite using this how-to site for reference and largely copying the code over: https://javascript.plainenglish.io/strava-api-react-app-326e63527e2c. Is this not a valid request link: 

https://www.strava.com/api/v3/athlete/activities?access_token=<access_token_here>? Of course, that <access_token_here> part is where my current access token would be, which gets refreshed with the way I've set up my React App.js file. 
 
For extra context, I am receiving a 401 request error upon the request being made in React:
The underlying error appears to be the following:

Not sure how to interpret this result.

 
I'd appreciate any help/insight into this for those of you who are aware of a fix/solution and/or have gone through this problem already.

Best answer by reesmonty

It turned out I just didn't have the right refresh token. Once I had that, everything worked as expected and I was able to pull in data to my React app.

View original

4 replies

Forum|alt.badge.img+3
  • Hub Rookie
  • Feb 24, 2023 2:06 PM UTC

The access token does not go in the URL of the GET request, it goes in the 'Authorization' HTTP header of the request.

Read more here


ActivityFix
Forum|alt.badge.img+23
  • Hub Climber
  • Feb 24, 2023 2:54 PM UTC

The error message says you don't have read permissions. As part of the oauth flow you pass the requested scopes and the athlete can accept whichever ones they feel are appropriate. See https://developers.strava.com/docs/authentication/#detailsaboutrequestingaccess. The token you acquire will only grant access to the scopes the athlete authorized, so make sure you have either read or read_all

 


Forum|alt.badge.img+6
  • Author
  • Hub Rookie
  • Answer
  • Feb 25, 2023 10:41 PM UTC

It turned out I just didn't have the right refresh token. Once I had that, everything worked as expected and I was able to pull in data to my React app.


Michal11
Forum|alt.badge.img+6
  • Hub Explorer
  • Jun 9, 2026 11:06 AM UTC

Passing access tokens in urls isĀ  a very bad habit :) btw