Generate a token for the user and the desired scope. The user is sent to the strava authentication page if he/she hasn't given permission to the app yet, else, is sent to the app webpage.
strava_oauth(
app_name,
app_client_id,
app_secret,
app_scope = "public",
cache = FALSE
)
A Token2.0
object returned by oauth2.0_token
to be used with API function calls
chr string for name of the app
chr string for ID received when the app was registered
chr string for secret received when the app was registered
chr string for scope of authentication, Must be "read" , "read_all", "profile:read_all", "profile:write", "activity:read", "activity:read_all" or "activity:write"
logical to cache the token
The app_name
, app_client_id
, and app_secret
are specific to the user and can be obtained by registering an app on the Strava API authentication page: http://strava.github.io/api/v3/oauth/. This requires a personal Strava account.
if (FALSE) {
app_name <- 'myappname' # chosen by user
app_client_id <- 'myid' # an integer, assigned by Strava
app_secret <- 'xxxxxxxx' # an alphanumeric secret, assigned by Strava
# create the authentication token
stoken <- httr::config(
token = strava_oauth(
app_name,
app_client_id,
app_secret,
app_scope="activity:read_all"
)
)
# use authentication token
get_athlete(stoken, id = '2837007')
}
Run the code above in your browser using DataLab