Skip to content

Commit

Permalink
cli: some debug and readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexef committed Apr 11, 2014
1 parent 92f296d commit 5893294
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion wouso-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Run the shell using:

python client.py --token 'oauth_token=xxxx...' localhost:8000 --shell

Notice: in order to communicate to a https server, use the full address,
such as: `python client.py --authorize https://wouso.cs.pub.ro/2013`.


### With configuration

Expand All @@ -40,4 +43,4 @@ Run the shell using:

## Shell

Type 'help' for help and available methods.
Type 'help' for help and available methods.
9 changes: 7 additions & 2 deletions wouso-cli/wousoapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ def __init__(self, server, port=None, path='', consumer_key='', consumer_secret=
self.signature_method_hmac_sha1 = oauth.OAuthSignatureMethod_HMAC_SHA1()

def fetch_request_token(self, oauth_request):
headers = oauth_request.to_header()
logging.debug("Request token headers: " + str(headers))
self.connection.request(oauth_request.http_method, self.request_token_url,
headers=oauth_request.to_header())
headers=headers)
response = self.connection.getresponse()
data = response.read()
if 'Invalid consumer' not in data:
Expand All @@ -60,7 +62,9 @@ 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 oauth.OAuthToken.from_string(response.read())
data = response.read()
logging.debug("Received authorization data: " + data)
return oauth.OAuthToken.from_string(data)

def access_resource(self, oauth_request):
oauth_request.http_url = self.path + oauth_request.http_url
Expand Down Expand Up @@ -129,6 +133,7 @@ def authorize(self):

# Authorize access, get verifier
url = self.client.authorize_token(oauth_request)
logging.debug('Opening url: ' + url)
webbrowser.open_new(url)

verifier = raw_input('Please enter verifier:')
Expand Down

0 comments on commit 5893294

Please sign in to comment.