PageRenderTime 392ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/content/posts/2020-02-15-meetup-api-multiple-redirect-uris.md

https://gitlab.com/jamietanna/jvt.me
Markdown | 51 lines | 39 code | 12 blank | 0 comment | 0 complexity | c6e228a0b9574a4a0c1ded69e0274747 MD5 | raw file
  1. ---
  2. title: "Setting up Multiple `redirect_uri`s on the Meetup.com API"
  3. description: "How to allow multiple `redirect_uri`s on your Meetup.com (OAuth2) API consumer."
  4. tags:
  5. - blogumentation
  6. - oauth2
  7. - meetup.com
  8. license_code: Apache-2.0
  9. license_prose: CC-BY-NC-SA-4.0
  10. date: 2020-02-15T13:01:15+0000
  11. slug: "meetup-api-multiple-redirect-uris"
  12. image: https://media.jvt.me/aee708169e.png
  13. ---
  14. Since roughly September, I've been on-and-off working on [contributing a feature request](https://github.com/snarfed/bridgy/issues/873) to allow [Bridgy](https://brid.gy) to send RSVPs events from my personal website straight to Meetup.com.
  15. In the last couple of weeks I've got to the final hurdle - getting this to work with Bridgy's core application, which performs a few OAuth2 code flows - authorizing "listen" functionality (which is not implemented), authorizing "publish" functionality (which I've added) and authorizing to disable publishing.
  16. When asking Bridgy's author, <span class="h-card"><a class="u-url p-name" href="https://snarfed.org">Ryan Barrett</a></span>, about this, he mentioned that it was to stop anyone from going to your profile on Bridgy and disabling it - you needed to prove you owned the account before you made changes to it.
  17. To make this these flows easier, Ryan has set up a number of pre-built handlers for these flows, each of which are on different endpoints.
  18. However, the Meetup.com API does _not_ allow for multiple `redirect_uri`s, which has made this process much more complicated than it needed to be, and has been quite a painful learning experience.
  19. Getting quite annoyed with the complexity overhead of this approach, I set about trying my DuckDuckGo-fu and seeing if I could find anything online, but to no avail.
  20. So I then thought I'd look at whether I could modify the `redirect_uri` to add other URIs, on the off chance it worked.
  21. Trying with a comma didn't seem to work, but I noticed that when I removed a portion of the path, it still seemed to work. This means that with the pre-registered `redirect_uri=http://localhost:8080/meetup/`, I can use any of the following in OAuth2 code flows:
  22. ```
  23. http://localhost:8080/meetup/
  24. http://localhost:8080/meetup/add
  25. http://localhost:8080/meetup/publish/finish
  26. ```
  27. I was surprised this would work, as in the past I've seen OAuth2 Authorization Servers be very strict on the validation of a `redirect_uri`.
  28. However, if we look at [RFC 6749: The OAuth 2.0 Authorization Framework: Section 3.1.2.2.](https://tools.ietf.org/html/rfc6749#section-3.1.2.2), we can see that it is permitted as per the spec:
  29. ```
  30. The authorization server SHOULD require the client to provide the
  31. complete redirection URI (the client MAY use the "state" request
  32. parameter to achieve per-request customization). If requiring the
  33. registration of the complete redirection URI is not possible, the
  34. authorization server SHOULD require the registration of the URI
  35. scheme, authority, and path (allowing the client to dynamically vary
  36. only the query component of the redirection URI when requesting
  37. authorization).
  38. ```
  39. Hopefully this helps those of you still creating Meetup.com APIs, but I do wish that the API documentation would make it known that it's possible!