Question

I'm trying to hook my website to Meetup.com.
Instructions

Everything works when I request authorization. However when I try to get the access token, I keep getting:

http error 400: bad request.

Here is my code:

def meetupauth(request):

r =request.REQUEST
code = r['code']
state = r['state']

consumer = OAuthConsumer.objects.filter(apiservice_id=LINKEDINAPI)[0]

url_str = {'client_id' : consumer.token, 'client_secret' : consumer.tokensecret, 'grant_type' : 'authorization_code', 'redirect_uri' : 'http://127.0.0.1:8000/apiservice/meetupauth', 'code' : code}

#url_str = (('client_id' , consumer.token), ('client_secret' , consumer.tokensecret), ('grant_type' , 'authorization_code'), ('redirect_uri' , 'http://127.0.0.1:8000/apiservice/meetupauth'), ('code' , code))

url_string = urllib.urlencode(url_str)

req = urllib2.Request(meetup_access_token_url, url_string)


resp = urllib2.urlopen(req)


return redirect("/dashboard/")

This is the error:

HTTPError at /apiservice/meetupauth
HTTP Error 400: Bad Request
Request Method: GET
Request URL:    http://127.0.0.1:8000/apiservice/meetupauth?code=acd62b4e1f28e3454c322d6b00136443&state=
Django Version: 1.4
Exception Type: HTTPError
Exception Value:    HTTP Error 400: Bad Request
Was it helpful?

Solution

Dumb mistake.

the code is:

consumer = OAuthConsumer.objects.filter(apiservice_id=LINKEDINAPI)[0]

it should have been

consumer = OAuthConsumer.objects.filter(apiservice_id=MEETUPAPI)[0]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top