librelist archives

« back to archive

Flask-login auth tokens

Flask-login auth tokens

From:
Ben Judson
Date:
2012-10-15 @ 22:29
I have flask-login installed, and it seems to be setup correctly, but it 
is not using get_auth_token() to generate the session token, and also 
doesn't seem to be using the token_loader callback to check the user. 

If I call login_user(user), this returns true and I get the correct user 
with current_user. But the token the browser gets back is like this:

ic+hYM8PwAJEbYoiPwHolWKXzzw=?_fresh=STAxCi4=&_id=UydceGNid1x4MWFceGEwMngtXHhiYlx4YThfelx4OWRceGZkXHhlNFx4Y2VceGFjJwpwMQou&user_id=VjEKLg==

Whereas the one that would be generated by my custom get_auth_token() 
function looks like this:

WyIxIiwiPG1kNSBIQVNIIG9iamVjdCBAIDB4OGRmZWUwMD4iXQ.A14DpA.RVnWLVftRWzPGuoQluxu02bZMUA

If I call the relevant functions manually, everything seems to work:
u = app.login_manager.user_callback(unicode(id))
token = u.get_auth_token()
uu = app.login_manager.token_callback(token)
app.logger.debug(str(uu))

This logs the correct user with no problems. But the callbacks are never 
run when simply using the login_user() function, nor is get_auth_token().

Any ideas what I'm missing here?