Update: Needed to restart web2py (sorry I'm spoilt!) Ok it works as expected. It seems I need to unescape the "@" symbol in username before calling basic(). I was using the encoded %40 instead.
On Dec 29, 1:10 pm, Adi <aditya.sa...@gmail.com> wrote: > Sorry for the late response. I tried putting print statements in this > method, but I don't see anything on the console. Is there an option > while starting web2py to enable this? > > On Dec 15, 10:53 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > > Hmmm... look into gluon/tools.py > > > def basic(self): > > if not self.settings.allow_basic_login: > > return False > > basic = self.environment.request.env.http_authorization > > if not basic or not basic[:6].lower() == 'basic ': > > return False > > (username, password) = base64.b64decode(basic[6:]).split(':') > > return self.login_bare(username, password) > > > Can you add some print debug statements as see where it fails? > > > On Dec 15, 10:23 am, Adi <aditya.sa...@gmail.com> wrote: > > > > Hi, > > > > I'm trying to set up a function for authenticating users over a service. > > > > This is my method: > > > > def authenticate(): > > > > is_loggedin = auth and auth.user > > > > if not is_loggedin: > > > > auth.allow_basic_login = True > > > > is_loggedin = auth.basic() > > > > return is_loggedin > > > > This is how I call it: curl -u > > > a%40b.com:testhttp://127.0.0.1:8000/app/default/authenticate > > > > a...@b.com is the username, test is the password. This is returning > > > False when > > > I expected True. What am I missing?