0

How to create a custom login system with google-app-engine's User class?

I'm making my own login system. I have tried os.environ['USER_EMAIL'] = 'john.doe@example.com', but it doesn't work. I guess the information is not saved in a session, so if I visit another page then users.get_current_user() has no memory of what I had set it to previously.

I have seen google-app-engine unit tests that does this to fake a logins. I think these works because the tests are within the same session. I need to store my own custom information across multiple sessions.

I have also tried setting environment variables, but without luck.

os.environ['USER_EMAIL'] = 'john.doe@example.com'
os.environ['USER_ID'] = 'todo_user_id'
os.environ['USER_IS_ADMIN'] = '1'
os.environ['AUTH_DOMAIN'] = 'todo_auth_domain'
os.environ['FEDERATED_IDENTITY'] = 'todo_federated_identity'
os.environ['FEDERATED_PROVIDER'] = 'todo_federated_provider'
neoneye
  • 50,398
  • 25
  • 166
  • 151
  • 1
    Have you taken a look at http://stackoverflow.com/questions/1020736/custom-authentication-in-google-app-engine-python or http://stackoverflow.com/questions/994965/customize-login-in-google-app-engine ? – matt b Jul 15 '11 at 12:07
  • Is this just for testing locally or are you trying to manipulate the users service on the production servers? The latter will not be posible – Chris Farmiloe Jul 15 '11 at 12:13
  • This is for production. It's a backend for customers, so it's restricted to a few people with non-gmail accounts. I'm new to google-app-engine and the default login seems to allow access to anyone with a gmail account. – neoneye Jul 15 '11 at 12:18
  • http://code.google.com/appengine/articles/openid.html google app engine now support OpenID. – lucemia Jul 20 '11 at 17:48

1 Answers1

3

You can't - the Users API only supports signing in with methods supported by that API. If you want to implement your own signin, you will need to use a third-party session library and keep track of logged in users the 'regular' way.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198