Skip to content

Commit

Permalink
Added support for callback URL for oAuth authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-wilson committed Feb 7, 2012
1 parent e68eec8 commit b16f3f2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions vimeo/__init__.py
Expand Up @@ -64,10 +64,9 @@
# by default expects to find your key and secret in settings.py (django) # by default expects to find your key and secret in settings.py (django)
# change this if they're someplace else (expecting strings for both) # change this if they're someplace else (expecting strings for both)
try: try:
from settings import VIMEO_KEY, VIMEO_SECRET from settings import VIMEO_KEY, VIMEO_SECRET, VIMEO_CALLBACK_URL
except ImportError: except ImportError:
VIMEO_KEY, VIMEO_SECRET = None, None VIMEO_KEY, VIMEO_SECRET, VIMEO_CALLBACK_URL = None, None, None

LOG = False LOG = False


class VimeoError(Exception): class VimeoError(Exception):
Expand Down Expand Up @@ -250,8 +249,9 @@ class VimeoClient(object):
_NO_CACHE = ("vimeo_videos_upload_getTicket", _NO_CACHE = ("vimeo_videos_upload_getTicket",
"vimeo_videos_upload_getQuota") "vimeo_videos_upload_getQuota")


def __init__(self, key=VIMEO_KEY, secret=VIMEO_SECRET, format="xml", def __init__(self, key=VIMEO_KEY, secret=VIMEO_SECRET,
token=None, token_secret=None, cache_timeout=120): callback=VIMEO_CALLBACK_URL, format="xml", token=None,
token_secret=None, cache_timeout=120):
# memoizing # memoizing
self._cache = {} self._cache = {}
self._timeouts = {} self._timeouts = {}
Expand All @@ -265,6 +265,7 @@ def __init__(self, key=VIMEO_KEY, secret=VIMEO_SECRET, format="xml",


self.key = key self.key = key
self.secret = secret self.secret = secret
self.callback = callback
self.consumer = oauth2.Consumer(self.key, self.secret) self.consumer = oauth2.Consumer(self.key, self.secret)


# any request made with the .client attr below is automatically # any request made with the .client attr below is automatically
Expand Down Expand Up @@ -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 Internal method that gets a new token from the request_url and sets it
to self.token on success. 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): if self._is_success(resp):
new_token = dict(urlparse.parse_qsl(content)) new_token = dict(urlparse.parse_qsl(content))
Expand Down

0 comments on commit b16f3f2

Please sign in to comment.