Getting Started
When using this package to access the Strava API, you should use an instance StravaHttpService
, which provides an object-oriented implementation of the Strava API.
Beloe you'll find examples on how to create a new instance from either an access token or a refresh token. If you don't already have either of those, you can read more how to obtain these on the Authentication page.
From an access token
The StravaHttpService
class contains a static CreateFromAccessToken
method that let's you create a new instance from an access token:
@using Skybrud.Social.Strava
@{
// Initialize a new instance from an access token
StravaHttpService strava = StravaHttpService.CreateFromAccessToken("Your access token");
}
This example on it's own doesn't result in any requests to the Strava API.
From a refresh token
If you wish to acces the Strava API periodically without sending the user through the OAuth authorization flow each time, you can use a refresh token to create a new StravaHttpService
instance via the static GetAccessTokenFromRefereshTokenAsync
.
@using Skybrud.Social.Strava
@{
// Initialize a new HTTP service from a refresh token
StravaHttpService strava = await StravaHttpService.CreateFromRefreshTokenAsync("Your client ID", "Your client secret", "The refresh token");
}
Under the hood, this will make a request to the Strava API to exchange the refresh token with a new access token. Ideally you should re-use this access token until it expires instead of creating a new access token repeateadly.