3

I created an app on Strava. Authorized my app on my account with read,activity:read,activity:read_all,read_all permissions.

I didn't want polling their API for activities as they recommend webhooks for that.

So I created a webhook subscription and validated it via the callback url.

Here's the response of Strava API for the webhook subscriptions I successfully created:

    [
        {
            "id": 179***,
            "resource_state": 2,
            "application_id": 59***,
            "callback_url": "http://*************.duckdns.org:8100/strava/webhook",
            "created_at": "2021-01-22T20:42:46Z",
            "updated_at": "2021-01-22T20:42:46Z"
        }
    ]

My problem is that I'm not receiving any activity events.

The only event I get is the revoke access event when I delete my app from my account.

{
    'aspect_type': 'update', 
    'event_time': 1611350203, 
    'object_id': 6881533, 
    'object_type': 'athlete', 
    'owner_id': 6881533, 
    'subscription_id': 179***, 
    'updates': {'authorized': 'false'}
}

So this indicates that my side is correct because event is received.

I tried sending an email to Strava but all I got was a auto-response telling me to use Strava API Google Groups for help, which was not helpful at all.

Does anyone have any clue what is wrong?

Sinan Cetinkaya
  • 427
  • 5
  • 18

1 Answers1

4

Finally solved my problem and writing the solution here for other people. Probably the people who don't have this problem are using libraries for Strava in their coding languages which already obtain access_token and refresh_token after the authorization.

If you're dealing with Strava Webhook API yourself like me, after the authorization, you must obtain your access_token and refresh_token as explained here https://developers.strava.com/docs/getting-started/#oauth

Strava Webhook API documentation doesn't say anything about this because access_token is not needed for creating a webhook subscription. Strava API creates a subscription and returns a successful response. This is misleading because your endpoint won't get any webhook events

Sinan Cetinkaya
  • 427
  • 5
  • 18
  • I have the same problem. Could you please explain where you use access and refresh tokens in webhooks since webhooks are only callbacks? – Vladimir Berezkin Jan 03 '22 at 17:36
  • @VladimirBerezkin it's been a long time. `access_token` is not needed for creating a webhook subscription. However if your `access_token` is not up to date you need to update it using `refresh_token`. You need to check `expires_at` epoch time in the json response from `https://www.strava.com/api/v3/oauth/token` – Sinan Cetinkaya Jan 03 '22 at 18:11
  • @SinanÇetinkaya Does webhook allow us to subscribe for multiple users? If it allows, how could the subscription know which user it should listen to? – Hoang Lam Aug 10 '22 at 09:20
  • @HoangLam Docs describe that each application can only have one subscription but that each subscription will allow a push for any athlete who has authorized the single app. https://developers.strava.com/docs/webhooks/ – vizyourdata Mar 13 '23 at 05:24
  • I don't think this answer is correct, once you have managed to subscribe, there is no need for access or refresh token. Strava will hit your callback endpoint and in the body of the POST request it should include event data. I have the same problem, I'm getting all the events from STRAVA to my callback endpoint, but updates object is empty – luk Mar 19 '23 at 17:14
  • @luk I posted this 2 years ago, something might have been fixed/changed. I'm still using this way and I get all the events, including updates – Sinan Cetinkaya Mar 19 '23 at 22:55
  • 1
    @luk I just changed an activity name and here's the webhook event response: [ { "aspect_type": "update", "event_time": 1679266775, "object_id": 8742218858, "object_type": "activity", "owner_id": 688XXXX, "subscription_id": 186XXX, "updates": { "title": "Afternoon Run 2" } } ] – Sinan Cetinkaya Mar 19 '23 at 23:02
  • It is indeed working, I was assuming it might provide more data in the payload for "create" aspect_type. – luk Mar 31 '23 at 13:56