2

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
whoan
  • 8,143
  • 4
  • 39
  • 48
anc1revv
  • 1,563
  • 7
  • 24
  • 42
  • Is this error occuring when the authorization redirects to your callback url? This error looks like its failing before even entering your access token view. – jdi Jul 16 '12 at 21:23
  • @jdi i get to the meetup "access granted" page, and when it redirects to this view i get the 400 error. I put a print statement after "r=request.Request" and terminal printed out the correct output – anc1revv Jul 16 '12 at 21:29
  • Is your `APPEND_SLASH` settings.py value set to True? If not, you might need to add an explicit `/` to the end of your `redirect_uri`. You should directly copy-paste and request url to your browser and see if you get a 404 – jdi Jul 16 '12 at 21:40

1 Answers1

1

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]
anc1revv
  • 1,563
  • 7
  • 24
  • 42