-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the JSON object must be str, not 'bytes' #491
Comments
I didn't test with Django 1.7 and python 3.4 just yet. |
I am having the same problem when using |
Really loving this package @tschellenbach! |
I'm working on a fix here: 7d1219b . Though not finalised yet so do not use it. It would be very nice if people would test this fix =) I'm working on the tests now and I will release potential fixes for those ASAP. |
Great guys, much appreciated! |
@tschellenbach I'm having a hard time to test this change. How can I run all tests locally and those specifically for I want to make sure this fix doesn't break anything in python 2, because all tests with python 2 should pass right? An official python 3 release is not out there yet, if I'm correct , so this is just a bonus for those using django-facebook in python 3 environment IMO. |
the current version is python 3 compatible in terms of test coverage. but not everything is tested |
have a look at how the travis.yml file runs the tests |
`json.loads` was expecting a string, but in python 3 `base64decode()` return bytes and that is why it bugged. We fix this by making sure the decoded payload data is in string and that `hmac.new()` is provided with arguments in bytes. `open_facebook.utils.smart_str` will do that job correctly in python 2 and 3. We also use `hmac.compare_digest()` which is the preferred way to compare those kinds of data to prevent timing analysis. Read more about this on python docs. Though this is only available from python 2.7.7. Fixes tschellenbach#491.
`json.loads` was expecting a string, but in python 3 `base64decode()` return bytes and that is why it bugged. We fix this by making sure the decoded payload data is in string and that `hmac.new()` is provided with arguments in bytes. `open_facebook.utils.smart_str` will do that job correctly in python 2 and 3. We also use `hmac.compare_digest()` which is the preferred way to compare those kinds of data to prevent timing analysis. If not `hmac.compare_digest` is available (python 2.7.7+) then we just compare logically. Fixes tschellenbach#491.
`json.loads` was expecting a string, but in python 3 `base64decode()` return bytes and that is why it bugged. We fix this by making sure the decoded payload data is in string and that `hmac.new()` is provided with arguments in bytes. `open_facebook.utils.smart_str` will do that job correctly in python 2 and 3. We also use `hmac.compare_digest()` which is the preferred way to compare those kinds of data to prevent timing analysis. If not `hmac.compare_digest` is available (python 2.7.7+) then we just compare logically. Fixes tschellenbach#491.
The snippet [https://github.com/tschellenbach/Django-facebook/commit/7d1219b36ef9318495032d8dd0626d11b45fbf9a] looks to work for me. I'm running python 3.4.3 |
I have the same problem... i'm using django 1.8.5 and python 3.4.2, but when i go to /facebook/connect/ my project crash... this is my traceback: Traceback: Exception Type: TypeError at /facebook/connect/ |
`json.loads` was expecting a string, but in python 3 `base64decode()` return bytes and that is why it bugged. We fix this by making sure the decoded payload data is in string and that `hmac.new()` is provided with arguments in bytes. `open_facebook.utils.smart_str` will do that job correctly in python 2 and 3. We also use `hmac.compare_digest()` which is the preferred way to compare those kinds of data to prevent timing analysis. If not `hmac.compare_digest` is available (python 2.7.7+) then we just compare logically. Fixes tschellenbach#491.
When trying to log in with Facebook on /facebook/example/ , this is what I get:
TypeError at /facebook/connect/
the JSON object must be str, not 'bytes'
Request Method: POST
Request URL: http://www.example.com/facebook/connect/
Django Version: 1.7
Exception Type: TypeError
Exception Value:
the JSON object must be str, not 'bytes'
Exception Location: /usr/local/lib/python3.4/json/init.py in loads, line 312
Python Executable: /usr/home/eric/virtualenvs/djangovirt/bin/python
Python Version: 3.4.1
Python Path:
['/usr/home/eric/virtualenvs/djangovirt/djangoproj',
'/usr/local/lib/python34.zip',
'/usr/local/lib/python3.4',
'/usr/local/lib/python3.4/plat-freebsd10',
'/usr/local/lib/python3.4/lib-dynload',
'/usr/home/eric/virtualenvs/djangovirt/lib/python3.4/site-packages',
'/usr/home/eric/virtualenvs/djangovirt']
Server time: Wed, 15 Oct 2014 16:09:34 +0800
The text was updated successfully, but these errors were encountered: