Skip to content
Browse files

deal with a verifier

  • Loading branch information...
1 parent a6f6474 commit 38ddd6eaed5cafa43281e6e93a4eaa705996eebd @brosner brosner committed Dec 29, 2009
Showing with 12 additions and 8 deletions.
  1. +11 −7 contacts_import/oauth_consumer.py
  2. +1 −1 contacts_import/views.py
View
18 contacts_import/oauth_consumer.py
@@ -86,25 +86,29 @@ def fetch_unauthorized_token(self):
raise ServiceFail()
raise
- def authorized_token(self, token):
+ def authorized_token(self, token, verifier=None):
+ parameters = {}
+ if verifier:
+ parameters.update({
+ "oauth_verifier": verifier,
+ })
request = oauth.Request.from_consumer_and_token(self.consumer,
token = token,
http_url = self.access_token_url,
http_method = "POST",
- parameters = {
- "oauth_verifier": "", # linkedin requires this it seems
- }
+ parameters = parameters,
)
request.sign_request(self.signature_method, self.consumer, token)
try:
return oauth.Token.from_string(self._oauth_response(request))
except KeyError:
raise ServiceFail()
- def check_token(self, unauth_token, given_token):
+ def check_token(self, unauth_token, parameters):
token = oauth.Token.from_string(unauth_token)
- if token.key == given_token:
- return self.authorized_token(token)
+ if token.key == parameters.get("oauth_token", "no_token"):
+ parameters.get("oauth_verifier")
+ return self.authorized_token(token, verifier)
else:
return None
View
2 contacts_import/views.py
@@ -102,7 +102,7 @@ def oauth_callback(request, service):
if unauth_token is None:
ctx.update({"error": "token_missing"})
else:
- auth_token = consumer.check_token(unauth_token, request.GET.get("oauth_token", "no_token"))
+ auth_token = consumer.check_token(unauth_token, request.GET)
if auth_token:
request.session["%s_token" % service] = (auth_token.key, auth_token.secret)
return HttpResponseRedirect(reverse("import_contacts"))

0 comments on commit 38ddd6e

Please sign in to comment.
Something went wrong with that request. Please try again.