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.

API activity request with refresh capability for access token

reesmonty
Shkhara

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:
reesmonty_0-1677093783251.png
The underlying error appears to be the following:
reesmonty_0-1677094198893.png

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.
1 ACCEPTED SOLUTION

reesmonty
Shkhara

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 solution in original post

3 REPLIES 3

reesmonty
Shkhara

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.

ActivityFix
Superuser
Superuser

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

 

Bready
Mt. Kenya

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

getAthlete.png

Read more here