joestump / python-oauth2

A fully tested, abstract interface to creating OAuth clients and servers.
MIT License
2.99k stars 912 forks source link

Internal Server Error: object supporting the buffer API required #203

Closed speedingdeer closed 8 years ago

speedingdeer commented 8 years ago

Hi, I'm on python 3.4.0 and python-oauth2 1.9. The doc says it supports python up to 3.4 but it doesn't work for me.

Traceback (most recent call last): File "/Users/speedingdeer/code/.../pyvenv3.4/lib/python3.4/site-packages/bottle.py", line 862, in _handle return route.call(*_args) File "/Users/speedingdeer/code/.../pyvenv3.4/lib/python3.4/site-packages/bottle.py", line 1732, in wrapper rv = callback(_a, ka) File "server.py", line 242, in do_oauth_callback resp, content = client.request(request_url, 'GET') File "/Users/speedingdeer/code/.../pyvenv3.4/lib/python3.4/site-packages/oauth2/init.py", line 687, in request connection_type=connection_type) File "/Users/speedingdeer/code.../pyvenv3.4/lib/python3.4/site-packages/httplib2/init.py", line 1314, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) File "/Users/speedingdeer/code/.../pyvenv3.4/lib/python3.4/site-packages/httplib2/init.py", line 1116, in _request headers=headers, redirections=redirections - 1) File "/Users/speedingdeer/code/.../pyvenv3.4/lib/python3.4/site-packages/oauth2/init.py", line 673, in request req.sign_request(self.method, self.consumer, self.token) File "/Users/speedingdeer/code/.../pyvenv3.4/lib/python3.4/site-packages/oauth2/init**.py", line 493, in sign_request self['oauth_body_hash'] = base64.b64encode(sha1(self.body).digest()) TypeError: object supporting the buffer API required

Do you know something about this issue?

jaitaiwan commented 8 years ago

Taking a look, it means that self.body isn't an object that has a buffer api... What are you passing in as the body?

speedingdeer commented 8 years ago

I've been fallowing this code: http://blog.jaarce.com/2012/07/facebook-and-twitter-authentication.html so you can simply copy paste it. on 2.7 it works just fine, on 3.4 3.5 it doesn't.

jaitaiwan commented 8 years ago

Python-oauth2 is backwards compatible with 2.7, but I'd say there's some differences in the code you linked to that are not compatible. Can you reduce the code to replicate the issue into the smallest possible form?

On Wed, 13 Jan 2016 at 12:16 Filip Wiśniewski notifications@github.com wrote:

I've been fallowing this code: http://blog.jaarce.com/2012/07/facebook-and-twitter-authentication.html so you can simply copy paste it. on 2.7 it works just fine, on 3.4 3.5 it doesn't.

— Reply to this email directly or view it on GitHub https://github.com/joestump/python-oauth2/issues/203#issuecomment-171133331 .

speedingdeer commented 8 years ago

Yes I can, I won't do it now cause it's late night in my timezone, but I will put you here the snippet tomorrow.

jaitaiwan commented 8 years ago

Hey @speedingdeer how'd you go?

rickhanlonii commented 8 years ago

Bump @speedingdeer

njohnsn commented 8 years ago

Here is the code I'm trying to use from the wiki:

#!/local/web/.local/bin/python3.5

import oauth2 as oauth

# Create your consumer with the proper key/secret
consumer = oauth.Consumer(key="<KEY>",
    secret="<SECRET>")

# Request Token URL for ClearPass
request_token_url = "<URL>"

# Create our client
client = oauth.Client(consumer)

# The OAuth Client request works just like httplib2 for the most part
(resp, content) = client.request(request_token_url,"GET")
print(resp)
print(content)
njohnsn commented 8 years ago

Nevermind, I was using a GET when I needed to POST.

Thanks. -Neil

ivishnevs commented 7 years ago

may be this PR can fix this issue )