Hi, You could have a look at python-social-auth<https://github.com/omab/python-social-auth> and if you like it and don't know how to integrate it, have a look at this plugin <https://code.google.com/p/w2p-social-auth/> to integrate it in web2py. Quint
On Wednesday, February 19, 2014 12:33:29 AM UTC+1, James Q wrote: > I have a feeling that this topic comes up often, but I cannot seem to > Google a good solution to this. Essentially, I want users to be able to > login using either the built in Auth, or login via some Oauth provider, > like Twitter and Facebook. I have seen previous solutions using > ExtendedLoginForm and custom Twitter classes that inherit from > OAuthProvider, but they no longer seem to work. The Twitter code I find no > longer supports the newest Twitter API; the linkedin code from the web2py > book also does not work. > > Here is sample code I have now, which only seems to constantly redirect me > to the logout page: > > 1) Created new web2py application by copying the welcome one to a folder > named 'oauth' > 2) Added this code to db.py (taken from multiple examples online): > > from gluon.contrib.login_methods.oauth10a_account import OAuthAccount > from oauth2 import Client, Consumer, Token > > class TwitterAccount(OAuthAccount): > AUTH_URL = "http://twitter.com/oauth/authorize" > TOKEN_URL = "https://twitter.com/oauth/request_token" > ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token" > CLIENT_ID = "..." > CLIENT_SECRET = "..." > > def __init__(self, g): > OAuthAccount.__init__(self, g, self.CLIENT_ID, self.CLIENT_SECRET, > self.AUTH_URL, self.TOKEN_URL, self.ACCESS_TOKEN_URL) > > def get_user(self): > if self.accessToken() is not None: > consumer = Consumer(key=self.CLIENT_ID, > secret=self.CLIENT_SECRET) > client = Client(consumer, self.accessToken()) > resp, content = client.request(' > http://api.twitter.com/1/account/verify_credentials.json') > if resp['status'] != '200': > # cannot get user info. should check status > #redirect("http://google.com") > return None > u = json.loads(content) > return dict(first_name = u['name'], username=u['screen_name'], > name=u['name'], registration_id=u['id']) > > auth.settings.login_form=TwitterAccount(g=globals()) > > 3) Going to 127.0.0.1/oauth/user/login redirects me to user/logout. > > > Besides my frustration in trying to find timely information about this, is > there working code out there that is *recent*, in that it works with latest > web2py and the latest Oauth implementations? I'd really appreciate any tips > or hints anyone has. > > > -- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

