Does oauth2.0 work with python3?

104 views
Skip to first unread message

Dragan Matic

unread,
Sep 23, 2021, 6:06:17 AM9/23/21
to web2py-users

I have the oauth2.0 login enabled in my application as shown in the oauth2.0 example in the web2py book using google and facebook as providers.
The application uses python2 and I am now trying to convert it to python 3 and I am getting the following error:

TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

error1.png

I have solved that by adding the "b" before the token url like this:


but now I have the following error:

AttributeError: 'int' object has no attribute 'decode'

error2.png

Is anybody using oauth2.0 with python3 and if yes, what changes need to be made to the code?


Murat KAŞIKÇIOĞLU

unread,
Sep 24, 2021, 1:21:09 AM9/24/21
to web...@googlegroups.com
Hi Dragan,
I used this when upgrading. Maybe it helps you:
try:
    # For Python 3.0 and later
    from urllib.request import urlopen
except ImportError:
    # Fall back to Python 2's urllib2
    from urllib2 import urlopen

Best regards,
Murat. 




Dragan Matic <perakoj...@gmail.com>, 23 Eyl 2021 Per, 13:06 tarihinde şunu yazdı:
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5acd20a7-75e1-4b6e-895c-d7c47785145bn%40googlegroups.com.

Noobie

unread,
Oct 5, 2021, 9:49:09 AM10/5/21
to web2py-users

hi can you send me working code.... i am tired to set my codes straight

Bhargava Kamath

unread,
Oct 5, 2021, 9:51:25 AM10/5/21
to web2py-users
hi can you send me working code, i am fiddling with similar issue,

On Friday, September 24, 2021 at 10:51:09 AM UTC+5:30 muratkas...@gmail.com wrote:

Dragan Matic

unread,
Oct 9, 2021, 10:37:15 AM10/9/21
to web2py-users
It was a problem in the web2py/oauth20_account.py. A fix is in the repository now, but until a new stable version comes out this is what you need to change:

Reply all
Reply to author
Forward
0 new messages