Okay, thanks.

How do I authenticate the remote user?

Is there a slice on this?

Also, OAuth2 server for web2py?

On Wed, Jan 2, 2013 at 7:05 AM, Niphlod <[email protected]> wrote:

> seems a bug with python
>
> http://bugs.python.org/issue5285
>
>
>
>
>
> On Tuesday, January 1, 2013 7:53:56 PM UTC+1, Alec Taylor wrote:
>>
>> I have written a very simple function for testing auth; via REST:
>>
>> @service.jsondef login():
>>     try:
>>         args = json.loads(request.body.read()**)
>>         username = HTMLParser.unescape.__func__(H**TMLParser, args['user'])
>>         password = HTMLParser.unescape.__func__(H**TMLParser, args['pass'])
>>         return dict(auth_succeeded=str(auth.l**ogin_bare(username, 
>> password)))
>>     except ValueError, KeyError:
>>         raise HTTP(400, 'Invalid data received')
>>
>>
>> Unfortunately this gives me the following traceback:
>>
>> Traceback (most recent call last):
>>   File "web2py\gluon\restricted.py", line 212, in restricted
>>     exec ccode in environment
>>   File "web2py\applications\foo\**controllers/api.py", line 35, in
>> <module>
>>   File "web2py\gluon\globals.py", line 193, in <lambda>
>>     self._caller = lambda f: f()
>>   File "web2py\applications\foo\**controllers/api.py", line 16, in login
>>     return dict(auth_succeeded=str(auth.**login_bare(username,
>> password)))
>>   File "web2py\gluon\tools.py", line 1798, in login_bare
>>     if not user.registration_key and password == user[passfield]:
>>   File "web2py\gluon\validators.py", line 2654, in __eq__
>>     h = simple_hash(self.password, key, salt, digest_alg)
>>   File "web2py\gluon\utils.py", line 81, in simple_hash
>>     int(keylen), get_digest(alg))
>>   File "web2py\gluon\contrib\pbkdf2.**py", line 55, in pbkdf2_hex
>>     return pbkdf2_bin(data, salt, iterations, keylen,
>> hashfunc).encode('hex')
>>   File "web2py\gluon\contrib\pbkdf2.**py", line 65, in pbkdf2_bin
>>     mac = hmac.new(data, None, hashfunc)
>>   File "C:\usr\bin\Python27\lib\hmac.**py", line 133, in new
>>     return HMAC(key, msg, digestmod)
>>   File "C:\usr\bin\Python27\lib\hmac.**py", line 72, in __init__
>>     self.outer.update(key.**translate(trans_5C))
>> TypeError: character mapping must return integer, None or unicode
>>
>> How do I get this simple test-case working?
>>
>> Thanks for all suggestions,
>>
>> Alec Taylor
>>
>  --
>
>
>
>

-- 



Reply via email to