Twitter is on OAuth 1.0a so you must use gluon.contrib.login_methods. oauth10a_account
https://dev.twitter.com/docs/auth/oauth If you get too many redirection check what you get as token. install the ipdb module on your machine: $ pip install ipdb then add the following at the beginning of the get_user metod: import ipdb ipdb.set_trace() a debugger will start on the console where you started web2py every time the program flow hits those lines. Inspect what you get as token and what you get from the call to verify_credential on Twitter rest API. P.S. to remain compatible in case of future modifications to that module change the line: token = current.session.access_token to token = self.accessToken() 2014-05-16 17:36 GMT+02:00 Frank Buibish <[email protected]>: > I just downloaded web2py like a month and a half ago. How do I check if I > have the latest version? but I'm pretty sure it's a oauth issue. So I was > able to use firefox to trace the networks calls and the response was empty, > however I went to the logs directory and it's empty. I am on a Mac is there > anything I need to run to get the logs working? I thought it was just a > executable? > > On a side note here is the module I am using to authenticate: > > from gluon import * > from gluon.contrib.login_methods.oauth10a_account import OAuthAccount > import oauth2 as oauth > import gluon.contrib.simplejson as json > import twitter > from urlparse import parse_qsl > > > class TwitterAccount(OAuthAccount): > def get_user(self): > if self.accessToken() is None: > return > > client = oauth.Client(self.consumer, self.accessToken()) > url = 'http://api.twitter.com/1/account/verify_credentials.json' > resp, content = client.request(url) > > if resp['status'] != '200': > return None > u = json.loads(content) > > token = current.session.access_token > > return dict(name=u['name'], > username=u['screen_name'], > registration_id=u['id']) > > This results in too many redirects error, but when I change > > from gluon.contrib.login_methods.oauth10a_account import OAuthAccount > > to > > from gluon.contrib.login_methods.oauth20_account import OAuthAccount > > this results in twitter saying: > > Whoa there! > > There is no request token for this page. That's the special key we need from > applications asking to use your Twitter account. Please go back to the site > or application that sent you here and try again; it was probably just a > mistake. > > > Should I be using the App-only authentication in the twitter application > settings? aka this: > > https://api.twitter.com/oauth2/token > > because this is what I have set in my data module: > AUTH_URL="https://api.twitter.com/oauth/authorize" > TOKEN_URL="https://api.twitter.com/oauth/request_token" > ACCESS_TOKEN_URL="https://api.twitter.com/oauth/access_token" > > and in my db.py: > > if session.auth_with: > if session.auth_with == 'twitter': > from applications.Project.modules import twitter_account > toa = local_import('twitter_oauth_data') > CLIENT_ID = toa.CLIENT_ID > CLIENT_SECRET = toa.CLIENT_SECRET > AUTH_URL = toa.AUTH_URL > TOKEN_URL = toa.TOKEN_URL > ACCESS_TOKEN_URL = toa.ACCESS_TOKEN_URL > > auth.settings.login_form = twitter_account.TwitterAccount(globals(), > CLIENT_ID, > CLIENT_SECRET, > AUTH_URL, TOKEN_URL, > ACCESS_TOKEN_URL) > > Like I said I'm new to python and really web development in general, also > thanks for the quick reply. > > On Thursday, May 15, 2014 5:34:32 PM UTC-4, Michele Comitini wrote: >> >> First check that you are on latest stable version of web2py. Google >> has changed suddenly a fundamental HTTP header this is now correctly >> managed inside web2py. >> >> Check that you have web2py's session object working properly. >> >> If you are still having issues, just press F12 (either chrome or ffox >> will do) and look at all the request response sequence that happens >> inside the browser. If there is an error it's likely that you will >> see some message by looking at the response content. >> >> If no error comes up in the browser check web2py logs carefully for >> errors happening inside web2py's oauth module. >> >> >> >> 2014-05-15 15:59 GMT+02:00 Frank Buibish <[email protected]>: >> > I'm having the same issue with no luck, and I am new to python >> > development. >> > What exactly should I be looking for in the network request trace? or >> > how do >> > i check my OAuth configuration? >> > >> > >> > On Friday, December 6, 2013 12:49:24 PM UTC-5, Michele Comitini wrote: >> >> >> >> That error is usually caused by misconfigured OAuth, but there are >> >> different possible causes, the best way to find out is to trace all >> >> network >> >> requests using firefox firebug or chromium developer tools. >> >> >> >> >> >> 2013/12/6 Cássio Botaro <[email protected]> >> >>> >> >>> I made chages but doesn't work. >> >>> >> >>> Look the error: >> >>> >> >>> >> >>> https://drive.google.com/file/d/0B8vO2VBhd7XVeF9WOW9aRlZ4Y28/edit?usp=sharing >> >>> >> >>> -- >> >>> 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. >> >> >> >> >> > -- >> > 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/d/optout. > > -- > 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/d/optout. -- 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/d/optout.

