Thanks a lot, Massimo! It worked! On Tue, Apr 6, 2010 at 10:36 AM, mdipierro <mdipie...@cs.depaul.edu> wrote: > you need in db.py > > auth.settings.allow_basic_login = True > > it defaults to False > > > On Apr 5, 9:21 pm, Alexei Vinidiktov <alexei.vinidik...@gmail.com> > wrote: >> Hello, >> >> I'm trying to make a desktop client written in Python 2.5 (on Windows) >> communicate with a web2py 1.76.5 based app using services. It works >> fine with services that don't require authentication, but I was >> wondering if I could make it authenticate the user with Basic >> authentication. >> >> I've read in the Python docs that xmlrpclib supports Basic authentication: >> >> " >> Both the HTTP and HTTPS transports support the URL syntax extension >> for HTTP Basic Authentication:http://user:p...@host:port/path. The >> user:pass portion will be base64-encoded as an HTTP `Authorization' >> header, and sent to the remote server as part of the connection >> process when invoking an XML-RPC method. >> " >> >> In my modified Welcome web2py app I've added the setting >> auth.settings.allow_basic_authentication = True in >> welcome/models/db.py >> >> I've decorated the private_call action like so: >> >> @auth.requires_login() >> def private_call(): >> return private_service() >> >> And I've added a test action getstring: >> >> @private_service.xmlrpc >> def getstring(): >> if auth.is_logged_in(): >> return "logged in!" >> else: >> return "not logged in!" >> >> In my desktop app I'm calling the service like this: >> >> self.server = >> xmlrpclib.Server("http://myem...@gmail.com:mypassw...@127.0.0.1:8000/welcome/default/private_call/xmlrpc") >> print self.server.getstring() >> >> and I'm getting this traceback: >> >> Traceback (most recent call last): >> File "C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py", line >> 137 >> , in OnButton4Button >> print self.server3.getstring() >> File "C:\Python25\lib\xmlrpclib.py", line 1147, in __call__ >> return self.__send(self.__name, args) >> File "C:\Python25\lib\xmlrpclib.py", line 1437, in __request >> verbose=self.__verbose >> File "C:\Users\Alexei\Documents\wxPython\Boa\xml_rpc_test\Frame1.py", line >> 185 >> , in request >> headers >> xmlrpclib.ProtocolError: <ProtocolError for myem...@gmail.com:mypassword@ >> 127.0.0.1:8000/welcome/default/private_call/xmlrpc: 303 SEE OTHER> >> >> I'm obviously doing something wrong. Could you point me in the right >> direction? >> >> Thanks. >> >> -- >> Alexei Vinidiktov > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to web...@googlegroups.com. > To unsubscribe from this group, send email to > web2py+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > >
-- Alexei Vinidiktov -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.