Permalink
Browse files

refactored oauth client + tweaked signing method

  • Loading branch information...
1 parent 950810e commit 6ee208015316b968a8b94dfb346883a39d870931 @dustinwhittle dustinwhittle committed Oct 13, 2009
Showing with 11 additions and 14 deletions.
  1. +1 −1 src/yahoo/application.py
  2. +10 −13 src/yahoo/oauth.py
View
@@ -77,7 +77,7 @@ def get_access_token(self, request_token, verifier=None):
else:
parameters = { 'oauth_verifier': verifier }
request = oauthlib.oauth.OAuthRequest.from_consumer_and_token(self.consumer, token=request_token, http_method='GET', http_url=self.client.access_token_url, parameters=parameters)
- request.sign_request(self.signature_method_hmac_sha1, self.consumer, request_token)
+ request.sign_request(self.signature_method_plaintext, self.consumer, request_token)
self.token = self.client.fetch_access_token(request)
return self.token
View
@@ -139,7 +139,7 @@ def from_string(s):
class Client(oauthlib.oauth.OAuthClient):
- def __init__(self, server='https://api.login.yahoo.com/.', port=httplib.HTTPS_PORT, request_token_url=REQUEST_TOKEN_API_URL, access_token_url=ACCESS_TOKEN_API_URL, authorization_url=AUTHORIZATION_API_URL):
+ def __init__(self, server='https://api.login.yahoo.com/', port=httplib.HTTPS_PORT, request_token_url=REQUEST_TOKEN_API_URL, access_token_url=ACCESS_TOKEN_API_URL, authorization_url=AUTHORIZATION_API_URL):
urlData = urlparse.urlparse(server)
self.server = urlData.netloc
@@ -153,20 +153,19 @@ def __init__(self, server='https://api.login.yahoo.com/.', port=httplib.HTTPS_PO
else:
self.connection = httplib.HTTPConnection("%s:%d" % (urlData.netloc, self.port))
+# self.connection.set_debuglevel(3)
+
def fetch_request_token(self, oauth_request):
- self.connection.request(oauth_request.http_method, self.request_token_url, headers=oauth_request.to_header())
- response = self.connection.getresponse()
- return RequestToken.from_string(response.read())
+ self.connection.request(oauth_request.http_method, self.request_token_url, headers=oauth_request.to_header('yahooapis.com'))
+ return RequestToken.from_string(self.connection.getresponse().read().strip())
def fetch_access_token(self, oauth_request):
- self.connection.request(oauth_request.http_method, self.access_token_url, headers=oauth_request.to_header())
- response = self.connection.getresponse()
- return AccessToken.from_string(response.read())
+ self.connection.request(oauth_request.http_method, self.access_token_url, headers=oauth_request.to_header('yahooapis.com'))
+ return AccessToken.from_string(self.connection.getresponse().read().strip())
def authorize_token(self, oauth_request):
- self.connection.request(oauth_request.http_method, self.authorization_url, headers=oauth_request.to_header())
- response = self.connection.getresponse()
- return response.read()
+ self.connection.request(oauth_request.http_method, self.authorization_url, headers=oauth_request.to_header('yahooapis.com'))
+ return self.connection.getresponse().read().strip()
def access_resource(self, oauth_request, body = None):
urlData = urlparse.urlparse(oauth_request.get_normalized_http_url())
@@ -183,6 +182,4 @@ def access_resource(self, oauth_request, body = None):
else:
connection.request(oauth_request.http_method, oauth_request.to_url())
- response = connection.getresponse()
-
- return response.read()
+ return connection.getresponse().read().strip()

0 comments on commit 6ee2080

Please sign in to comment.