Skip to content

Commit

Permalink
Merge pull request #25 from josuebrunel/dev
Browse files Browse the repository at this point in the history
Fixing  #24 and #23
  • Loading branch information
josuebrunel committed Jun 7, 2015
2 parents 52e1aad + c15f539 commit edc47af
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
36 changes: 36 additions & 0 deletions docs/oauth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BaseOAuth
==========

### **Definition**

#### *BaseOAuth(oauth_version, consumer_key, consumer_secret, \*\*kwargs)*

* ***consumer_key*** : Your consumer key
* ***consumer_secret*** : Your consumer secret
* ***kwargs*** :
- *base_url* : API Base url
- *callback* : Callback url, by default **'oob'**
- *from_file*: JSON File containing credentials
- *acess_token, access_secret, session_handle, token_time* for OAuth1
- *acess_token, token_type, refresh_token, token_time* for OAuth2

When **from_file** is not provided, **credentials** are saved in ***./secrets.json***

***OAuth1*** and ***OAuth2*** subclass ***BaseOAuth***

### **Methods**

#### *token_is_valid()*
Check if token is still valid

#### *refresh_access_token()*
Refresh access token

#### *handle()*
Get ***request token*** (OAuth1), redirect user to ***authorization url*** and get ***access token***

#### *generate_oauth2_headers*
Generates headers for ***OAuth2***

#### *oauth2_access_parser(raw_access)*
Decode ***raw_access*** response for ***OAuth2***
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ site_description: Documentation on the Yahoo-OAuth Library
site_author: Josue Kouka
pages:
- Home : index.md
- BaseOAuth: oauth.md
theme: readthedocs
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

__author__ = 'Josue Kouka'
__email__ = '[email protected]'
__version__ = "0.1.3"
__version__ = "0.1.4"

#requirements.txt
with open('requirements.txt') as f:
Expand Down
6 changes: 4 additions & 2 deletions yahoo_oauth/yahoo_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ def __init__(self, oauth_version, consumer_key, consumer_secret, **kwargs):
access_token : access token
access_token_secret : access token secret
from_file : file containing the credentials
base_url : Base url
"""
self.oauth_version = oauth_version
json_data = {}

if kwargs.get('from_file'):
logging.debug("Checking ")
Expand Down Expand Up @@ -122,7 +124,7 @@ def __init__(self, oauth_version, consumer_key, consumer_secret, **kwargs):
else:
self.session = self.oauth.get_session(token=self.access_token)

json_write_data(json_data, self.from_file)
json_write_data(json_data, vars(self).get('from_file','secrets.json'))


def handler(self,):
Expand All @@ -148,7 +150,7 @@ def handler(self,):
credentials = {'token_time': self.token_time}

if self.oauth_version == 'oauth1':
raw_access = self.oauth.get_raw_access_token(request_token, request_token_secret, params={"oauth_verifier": verifier})
raw_access = self.oauth.get_raw_access_token(request_token, request_token_secret, params={"oauth_verifier": self.verifier})
parsed_access = parse_utf8_qsl(raw_access.content)

self.access_token = parsed_access['oauth_token']
Expand Down

0 comments on commit edc47af

Please sign in to comment.