403 error when doing /activities api get request

48 views
Skip to first unread message

Blind Hydra

unread,
Dec 31, 2022, 9:25:43 PM12/31/22
to Strava API
I am developing a python script that pulls all my activities using the Strava API. I have been successful at pulling my access token using the "https://www.strava.com/oauth/token" API and my stats from 'https://www.strava.com/api/v3/athletes/58832723/stats

But when ever I try to pull the entire list of activities using "https://www.strava.com/api/v3/athlete/activities?access_token={access_token}&per_page1" I get a 403 error and a message that says "can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner." I also tried doing "https://www.strava.com/api/v3/athlete/activities" and I got the same result.

I am used two types of payloads to give Strava my credentials:
  • payload = {
    'client_id': "xxx",
    'client_secret': 'xxx',
    'code':'xxx',
    'grant_type': "authorization_code",
    'f': 'json'
    }
  • payload = {
    'client_id': "xxx",
    'client_secret': 'xxx',
    'refresh_token': 'xxx',
    'grant_type': "refresh_token",
    'f': 'json'
    }
None of these work for the activities API. Am I missing something from the authentication process or why is Strava not allowing my request? I also read something online about changing my privacy setting and I already set everything to public for my account, I hit a road block and any help would be deeply appreciated!! 

Blind Hydra

unread,
Dec 31, 2022, 9:32:29 PM12/31/22
to Strava API
I also want to add that I get this message when running the /activities get request:
  • {'message': 'Authorization Error', 'errors': [{'resource': 'AccessToken', 'field': 'activity:read_permission', 'code': 'missing'}]}

Richard M

unread,
Dec 31, 2022, 9:48:28 PM12/31/22
to Blind Hydra, Strava API
You need to request the activity:read scope:
 https://developers.strava.com/docs/authentication/#detailsaboutrequestingaccess
See the scopes section.

At the moment it looks like you just have access to basic public profile data.


Happy New Year!



--
You received this message because you are subscribed to the Google Groups "Strava API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strava-api+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/strava-api/fc3f3a28-6485-419b-a1c2-a2124d657872n%40googlegroups.com.

Blind Hydra

unread,
Jan 2, 2023, 3:58:24 PM1/2/23
to Richard M, Strava API
Hey Richard! Thanks for the fast reply, I truly appreciate it, also happy holidays and new year!

So to request access I have to create a separate API call or is this done through Strava's website? I am currently writing my app on python so I would have to create a payload with the inputs you sent in the documentation? I am a beginner using this API so I am still learning the ropes. 

Again, thanks for the support!

Best,

Blind Hydra

unread,
Jan 8, 2023, 1:33:50 PM1/8/23
to Richard M, Strava API
So if anybody else is having this issue when trying to run the GET Athlete Activities Requests using Strava API in python: 
  • {'message': 'Authorization Error', 'errors': [{'resource': 'AccessToken', 'field': 'activity:read_permission', 'code': 'missing'}]}
Screenshot 2023-01-08 at 12.23.05 PM.png

 After you authorize you will be redirected to this page:
Screenshot 2023-01-08 at 12.16.37 PM.png
Don't panic if you see the 'This site can't be reached' message, that's exactly what we want. From the web link, grab the code=xxxx, we will use that as our payload when running the python script.
My post request looks like this:
When you run this post request, save the access_token from the json that was generated and then you should be good to go to run the Activities GET request 

This is what my Activities Get request looks like: 
pages = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
activities_df = pd.DataFrame()
for i in pages:
activities_url = f"https://www.strava.com/api/v3/athlete/activities?access_token={access_token}&per_page=200&page={i}".format(i)
print('Requesting page number:',i)
response = requests.get(activities_url)
activity = response.json()
print(response)
activities_df = activities_df.append(activity, ignore_index=True)

This code of course could be optimized but it gets the job done! After this you shouldn't get the 'code':'missing' error! 
Reply all
Reply to author
Forward
0 new messages