Permalink
Browse files

Added support for callback URL for oAuth authentication.

  • Loading branch information...
1 parent e68eec8 commit b16f3f26926341106586565bde1981a0e8e9b7af @david-wilson david-wilson committed Feb 7, 2012
Showing with 13 additions and 6 deletions.
  1. +13 −6 vimeo/__init__.py
View
@@ -64,10 +64,9 @@
# by default expects to find your key and secret in settings.py (django)
# change this if they're someplace else (expecting strings for both)
try:
- from settings import VIMEO_KEY, VIMEO_SECRET
+ from settings import VIMEO_KEY, VIMEO_SECRET, VIMEO_CALLBACK_URL
except ImportError:
- VIMEO_KEY, VIMEO_SECRET = None, None
-
+ VIMEO_KEY, VIMEO_SECRET, VIMEO_CALLBACK_URL = None, None, None
LOG = False
class VimeoError(Exception):
@@ -250,8 +249,9 @@ class VimeoClient(object):
_NO_CACHE = ("vimeo_videos_upload_getTicket",
"vimeo_videos_upload_getQuota")
- def __init__(self, key=VIMEO_KEY, secret=VIMEO_SECRET, format="xml",
- token=None, token_secret=None, cache_timeout=120):
+ def __init__(self, key=VIMEO_KEY, secret=VIMEO_SECRET,
+ callback=VIMEO_CALLBACK_URL, format="xml", token=None,
+ token_secret=None, cache_timeout=120):
# memoizing
self._cache = {}
self._timeouts = {}
@@ -265,6 +265,7 @@ def __init__(self, key=VIMEO_KEY, secret=VIMEO_SECRET, format="xml",
self.key = key
self.secret = secret
+ self.callback = callback
self.consumer = oauth2.Consumer(self.key, self.secret)
# any request made with the .client attr below is automatically
@@ -399,7 +400,13 @@ def _get_new_token(self, request_url, *args, **kwargs):
Internal method that gets a new token from the request_url and sets it
to self.token on success.
"""
- resp, content = self.client.request(request_url, *args, **kwargs)
+ resp, content = self.client.request(
+ request_url,
+ "POST",
+ body=urlencode(
+ {'oauth_callback': self.callback}
+ )
+ )
if self._is_success(resp):
new_token = dict(urlparse.parse_qsl(content))

0 comments on commit b16f3f2

Please sign in to comment.