From 1a308c74e5e36d483de0201e6d94b31405d63510 Mon Sep 17 00:00:00 2001 From: josuebrunel Date: Sun, 26 Apr 2015 17:48:13 +0200 Subject: [PATCH] #12 : request_tokens and verifier not saved anymore --- myql/contrib/auth/auth.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/myql/contrib/auth/auth.py b/myql/contrib/auth/auth.py index c205f25..52e9b47 100644 --- a/myql/contrib/auth/auth.py +++ b/myql/contrib/auth/auth.py @@ -32,23 +32,25 @@ def __init__(self, consumer_key, consumer_secret, **kwargs): vars(self).update(kwargs) if not vars(self).get('access_token') and not vars(self).get('access_token_secret'): - - if not vars(self).get('request_token') and not vars(self).get('request_token_secret'): - self.get_request_token() - self.verifier = self.get_user_authorization() - self.get_access_token() - elif not vars(self).get('verifier'): - self.verifier = self.get_user_authorization() - self.get_access_token() - else: - self.get_access_token() - else: - self.oauth = OAuth1(self.consumer_key, client_secret=self.consumer_secret, resource_owner_key=self.access_token, resource_owner_secret=self.access_token_secret) + self.get_request_token() + self.verifier = self.get_user_authorization() + self.get_access_token() + # if not vars(self).get('request_token') and not vars(self).get('request_token_secret'): + # self.get_request_token() + # self.verifier = self.get_user_authorization() + # self.get_access_token() + # elif not vars(self).get('verifier'): + # self.verifier = self.get_user_authorization() + # self.get_access_token() + # else: + # self.get_access_token() + #else: + self.oauth = OAuth1(self.consumer_key, client_secret=self.consumer_secret, resource_owner_key=self.access_token, resource_owner_secret=self.access_token_secret) json_data.update({ - 'request_token': self.request_token, - 'request_token_secret': self.request_token_secret, - 'verifier': self.verifier, + #'request_token': self.request_token, + #'request_token_secret': self.request_token_secret, + #'verifier': self.verifier, 'access_token': self.access_token, 'access_token_secret': self.access_token_secret, 'session_handle': self.session_handle, @@ -72,8 +74,9 @@ def isValid(self): def refresh_token(self): """Refresh access token """ - oauth = OAuth1(self.consumer_key, resource_owner_key=self.access_token,resource_owner_secret=self.access_token_secret, callback_uri=CALLBACK_URI) - response = requests.post(REQUEST_TOKEN_URL, headers={'oauth_session_handle': self.session_handle}, auth=oauth) + oauth = OAuth1(self.consumer_key, resource_owner_key=self.access_token,resource_owner_secret=self.access_token_secret) + response = requests.post(ACCESS_TOKEN_URL, headers={'oauth_session_handle': self.session_handle}, auth=oauth) + pdb.set_trace() tokens = self.fetch_tokens(response.content) return tokens