OAuth2 + Twitter 'module' object has no attribute 'Consumer' error

1,602 views
Skip to first unread message

Luciano Laporta Podazza

unread,
Dec 21, 2013, 6:26:36 PM12/21/13
to
Hello,

I've been trying to integrate Facebook/Twitter login with Web2py 2.8.2-stable and OAuth2(the built-in oauth20_account.py) using this example:


Facebook login works but when I try the Twitter example I get this traceback:

Traceback (most recent call last):
File "/Users/keniobats/Downloads/web2py/gluon/restricted.py", line 217, in restricted
exec ccode in environment
File "/Users/keniobats/Downloads/web2py/applications/dugnading/models/db.py", line 167, in <module>
twitter_login = TwitterAccount(globals())
File "/Users/keniobats/Downloads/web2py/applications/dugnading/models/db.py", line 155, in __init__
self.ACCESS_TOKEN_URL)
File "/Users/keniobats/Downloads/web2py/gluon/contrib/login_methods/oauth10a_account.py", line 125, in __init__
self.consumer = oauth.Consumer(self.client_id, self.client_secret)
AttributeError: 'module' object has no attribute 'Consumer'
I've tried including the oauth2 module in web2py/sites-package and myapp/modules and still get the same error.
Also, I don't know why in the twitter example oauth2 is imported if Twitter is supposed to use oauth 1.0:
import oauth2 as oauth

I love web2py but i'm still a newbie. Any help will be appreciated. 

Thanks in advance.

Note: I don't want to use Janrain, indeed i'm looking for Facebook/Twitter/Regular login form auth.


Michele Comitini

unread,
Dec 21, 2013, 6:39:43 PM12/21/13
to web...@googlegroups.com
oauth2 is an unfortunate name chosen for a module that actually implements oauth1.0a: see https://pypi.python.org/pypi/oauth2

About the error check that you have installed the above package on your system.  You can do so in a python shell:

$ python
>>> import oauth2
>>> consumer = oauth2.Consumer
>>> print consumer




2013/12/21 Luciano Laporta Podazza <luciano...@gmail.com>

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Luciano Laporta Podazza

unread,
Dec 21, 2013, 7:04:06 PM12/21/13
to web...@googlegroups.com
Hello Michele!,

Well, it seems that I casually rebooted my Mac(OS X 10.9.1) and now magically works :P

>>> print consumer
<class 'oauth2.Consumer'>

Now i'm facing some issues with forms at Twitter/Facebook login so perhaps you'll see another new post from me.
Just in case, do you have some good(newer) examples of integrating multiple login methods?

Lot of thanks!.
Reply all
Reply to author
Forward
0 new messages