Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated Webhook API #185

Open
hobovsky opened this issue Sep 1, 2017 · 1 comment
Open

Outdated Webhook API #185

hobovsky opened this issue Sep 1, 2017 · 1 comment

Comments

@hobovsky
Copy link

hobovsky commented Sep 1, 2017

Hi Dan,

I tried to use webhook functionality of your library and had some problems. Probably API has changed on Strava side and library was not updated to reflect the changes. I noticed following discrepancies:

  • Host and endpoint address are different: api.strava.com vs www.strava.com, /push_subscriptions vs /subscriptions
  • Subscription aspect and object types should be sent as strings, but library sends their IDs as integers (request param names also changed)
  • Request should be sent as POST with form-encoded params, I believe.

It would be also nice to have tools for handling subscription negotiation, but luckily it's quite straightforward.

Now I'm trying to modify library code to make it work with web hooks, but I have to admit that my poor skills with Retrofit and HTTP in general won't help :( and manual changes can be easily lost anyway, for example when updating to new version of library.

Best regards and thank you for your great work,
Maciek

@hobovsky
Copy link
Author

hobovsky commented Sep 2, 2017

With a bit of effort I got subscriptions working. It's only 'create subscription' call, processing subscription verification callback and retrieving notifications themselves, I did not try to call 'list existing subscriptions', 'delete subscription', or any other webhook method. Here is a list of things I had to change to get things going:

  • Endpoint host name for webhook calls changed to https://api.strava.com/api/v3/ . Using 'regular' host name returns Strava login page HTML and causes JSON parsing error in Retrofit handler.
  • Endpoint path changed from subscriptions to push_subscriptions
  • Request method is POST, parameters are passed as url-encoded fields. Retrofit methods need annotations @ Post and @ FormUrlEncoded, parameters must be marked as @ Field.
  • StravaSubscriptionObjectType and StravaSubscriptionObjectType must be serialized as strings and not integers. Parameter names in web calls changed from object_type_id and aspect_type_id to object_type and aspect_type.
  • Webhook API calls are not performed in context of any authenticated athlete, so RequestInterceptor must not add Authorization header (otherwise you get "Bad request" response with "forbidden" code). I think it would be good if library provided a way to call webhook methods without a need for token.

Processing subscription confirmation callback is trivial, I got it working without any JSON, just with string concatenation, so there is no special need for support from library in this aspect. However it would be nice to have some simple tools to process subscription notifications. It also was not complicated and I got it working, but I think that some tools for parsing push notification request would fit nicely into library.

Best regards,
Maciek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant