Skip to content

Commit

Permalink
Unicode + indirection fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ib-lundgren committed May 23, 2013
1 parent 8eba282 commit 5570360
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions requests_oauthlib/oauth1_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

from . import OAuth1

import sys
if sys.version > "3":
unicode = str

to_unicode = lambda s: s if isinstance(s, unicode) else s.decode('utf-8')

This comment has been minimized.

Copy link
@omab

omab May 30, 2013

Any chance to get a new release with this bugfix?

This comment has been minimized.

Copy link
@Lukasa

Lukasa May 30, 2013

Member

As I said in #47, unless we find a giant crippling bug I'm not planning to push out a new release until the documentation is sorted out. =) We'd welcome some help on that front if you want to get the release out quicker...;)

This comment has been minimized.

Copy link
@omab

omab May 30, 2013

@Lukasa, fair enough, I can wait, meanwhile I've limited the version in requirements definition of python-social-auth. I would like to help with the doc, sadly I have to many things on my hands right now :(

Keep the good work.



class OAuth1Session(requests.Session):
"""Request signing and convenience methods for the oauth dance.
Expand Down Expand Up @@ -160,7 +166,7 @@ def authorization_url(self, url, request_token=None, **kwargs):
>>> oauth_session.authorization_url(authorization_url)
'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&oauth_callback=https%3A%2F%2F127.0.0.1%2Fcallback'
"""
kwargs['oauth_token'] = request_token or self._client.resource_owner_key
kwargs['oauth_token'] = request_token or self._client.client.resource_owner_key
return add_params_to_uri(url, kwargs.items())

def fetch_request_token(self, url):
Expand Down Expand Up @@ -244,13 +250,16 @@ def parse_authorization_response(self, url):

def _populate_attributes(self, token):
if 'oauth_token' in token:
self._client.resource_owner_key = token['oauth_token']
self._client.client.resource_owner_key = to_unicode(
token['oauth_token'])
else:
raise ValueError('Response does not contain a token. %s', token)
if 'oauth_token_secret' in token:
self._client.resource_owner_secret = token['oauth_token_secret']
self._client.client.resource_owner_secret = to_unicode(
token['oauth_token_secret'])
if 'oauth_verifier' in token:
self._client.verifier = token['oauth_verifier']
self._client.client.verifier = to_unicode(

This comment has been minimized.

Copy link
@justinas

justinas Jul 9, 2013

I think this one is enough of a crippling bug, at least for me. It caused the oauth_verifier not to be posted, so fetching access token didn't work at all.

token['oauth_verifier'])

def _fetch_token(self, url):
token = dict(parse_qsl(self.post(url).content))
Expand Down

0 comments on commit 5570360

Please sign in to comment.