Configuration
Create a strava-sync.php
file in your /config
directory. This will allow you to use the following options. You can also use multi-environment options to change these per environment. The defaults are shown below.
return [
'*' => [
'clientId' => null,
'clientSecret' => null,
'loginRedirect' => '/',
'onboardRedirect' => '',
'defaultUserGroup' => null,
'fieldMapping' => [],
'scope' => ''
]
];
# Available Options
Option | Type | Description |
---|---|---|
clientId | string | Client ID from Strava API |
clientSecret | string | Client Secret from Strava API |
loginRedirect | string | Where users are sent when successfully logged in via Strava |
onboardRedirect | string | Where users are sent to complete onboarding |
defaultUserGroup | integer | The user group Strava users are in by default |
fieldMapping | array | Map Strava data with User fields (See below) |
scope | string | What data you want to access from a Strava users profile |
# Field Mapping
You can map Strava athlete data https://www.strava.com/api/v3/athlete to user fields once the user has authorised and registered. This can only be done via the strava-sync.php
config file and the fieldMapping
option.
'fieldMapping' => [
'username' => 'id',
'firstName' => 'firstname',
'lastName' => 'lastname',
'userGender' => 'sex',
'userLocation' => 'country'
]
The key (E.g. username
) is the Craft CMS field your mapping to, and the value (e.g. id
) is the property from the Strava API Athelete GET https://www.strava.com/api/v3/athlete
# Scope
When you make an oAuth request you need to tell Strava what you require from that user. You may not require access to all of a users Strava data, e.g. You may only require to get an Athletes Details and not their Activities. To put trust in users authorising your website to connec to their Strava account it's important to choose the correct scope value when we make a oAuth call to Strava.
The scope setting is a comma seperated list, by default this is:
read, activity:read, read_all, activity:read_all, profile:read_all
You can see a list of available scope options at https://developers.strava.com/docs/oauth-updates/ under Details about requesting access.
# Control Panel
Some options might be customisable within the control panel by going to Settings → Strava Sync.