StravaSharp Library - 401- Unauthorized

49 views
Skip to first unread message

Mike Sheppard

unread,
May 24, 2021, 12:13:39 AM5/24/21
to Strava API
I'm using the StravaSharp Library for .NET.  I've created an API test account on my Strava account.  Using the Authorization Code, I'm able to information about the current athlete (me), but each time I try to return activities (GetAthleteActivities or GetAthleteActivitiesAfter) I get a 401 - Unauthorized error.  It appears my auth token is working to access my account, but I can't figure out why I can't return any activities.  Any help?
            DateTime start = new DateTime(2021, 1, 1);
            DateTime end = new DateTime(2021, 6, 1);

            TestAuthenticator auth = new TestAuthenticator("MY-AUTH-CODE-GOES-HERE");

            Client client = new Client(auth);
            
            var athlete = await client.Athletes.GetCurrent();
            String fname = athlete.FirstName;
            String lname = athlete.LastName;
            textBox1.Text = fname + " " + lname + "  " + athlete.FriendCount.ToString() + " " + athlete.Weight.ToString();
     // This above works fine and returns info about me.

            //THIS NEXT LINE THROWS A 401 ERRROR
            var activities = await client.Activities.GetAthleteActivities(start,end);

Thanks!

Mike

Mike Sheppard

unread,
May 24, 2021, 10:48:09 AM5/24/21
to Strava API
My son found the following article that explained how my default rights were just "read" and I needed to increase the scope of my rights:  Holding your hand through Strava’s API | by Jessica Salbert | Medium

Many thanks to Jessica!  I followed her instructions to change my scope to get all activities and now things are working fine.

Cheers,

Mike

kingo...@gmail.com

unread,
May 24, 2021, 11:03:24 AM5/24/21
to Strava API
You will also find this info at https://developers.strava.com/docs/authentication/
Reply all
Reply to author
Forward
0 new messages