Skip to content

Commit

Permalink
Add helper for POSTing to Meetup.com API
Browse files Browse the repository at this point in the history
As found with snarfed/granary#179, we need a convenient way to POST to
Meetup.com using the Bearer token.

The easiest way to do this is to amend our existing method and allow
passing through the request body `data`.
  • Loading branch information
jamietanna committed Dec 30, 2019
1 parent 0dfdd6e commit 44e2ed1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions oauth_dropins/meetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@
GET_USER_INFO_URL = 'https://api.meetup.com/members/self/'


def urlopen_bearer_token(url, access_token, **kwargs):
def urlopen_bearer_token(url, access_token, data=None, **kwargs):
"""Wraps urlopen() and adds OAuth credentials to the request.
"""
headers = {'Authorization': 'Bearer %s' % access_token}
try:
return util.urlopen(urllib.request.Request(url, headers=headers), **kwargs)
return util.urlopen(urllib.request.Request(url, headers=headers, data=data), **kwargs)
except BaseException as e:
util.interpret_http_exception(e)
raise


class MeetupAuth(BaseAuth):
"""An authenticated Meetup.com user.
Expand Down

0 comments on commit 44e2ed1

Please sign in to comment.