I’ve also used Strava Webhooks in Slava, my Strava bot for Slack. See slack-strava#78 for production code.
Here is how to run a full loop locally using strava-webhooks from strava-ruby-client. This is essential for local development and testing. I recommend doing this before writing any code for your own app.
Get a client ID and secret from Strava Settings, My API Application and set these as environment variables. You can also create a .env file in the current directory with these settings and the strava-webhooks tool will pick that up, export or specify these on the command line. YMMV.
Show Existing Subscriptions
Try strava-webhooks without any arguments. It should show you existing subscriptions, aka none.
Run a local webhook handler that responds to Strava pushing events with strava-webhooks handle.
Note that it starts on port 4242 by default.
Since your local machine is not addressable from the Internet, use ngrok, in another terminal.
This creates an HTTPs forwarding URL, eg. https://d3d0c6c4.ngrok.io.
Create a webhook subscription with strava-webhooks create [url].
The response contains a subscription ID of 136021.
Notice that the handler had to respond to a hub challenge.
Start by creating a manual activity for the same user. This will trigger an event that you can see in the handler window.
Delete the activity.
Authorized User Activities
To see other users’ events these must authorize your application. See Strava Authentication for implementation details.
Delete the Subscription
Delete the subscription with strava-webhooks delete [id].
The complete source code for strava-webhooks is here.