The fetchConfig method allows you to provide Strava credentials using one of three methods. If no argument is passed to fetchConfig(), the module attempts to load credentials from a local JSON file and environment variables.
1. Direct Configuration Object
You can pass a StravaConfig object directly to fetchConfig to override all other sources.
2. Configuration File
If fetchConfig() is called without arguments, it looks for a JSON file at data/strava_config. The file should contain a JSON object with the following keys:
access_tokenclient_idclient_secretredirect_uri
3. Environment Variables
If no object is provided and the config file is missing or incomplete, the module reads from the following environment variables:
STRAVA_ACCESS_TOKENSTRAVA_CLIENT_IDSTRAVA_CLIENT_SECRETSTRAVA_REDIRECT_URI
// Example: Direct configuration
const authenticator = require('./lib/authenticator');
authenticator.fetchConfig({
access_token: 'YOUR_ACCESS_TOKEN',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
redirect_uri: 'YOUR_REDIRECT_URI'
});