def authenticate(self, assertion=None, host='munchylunchy.com', port=80): result = API.verify_user(assertion=assertion) logging.error(str(result)) if result['result'] == 'okay': email = result['email'] token = result['token'] try: user = User.objects.get(username=email) user.password = token user.save() except User.DoesNotExist: user = User(username=email, password=token) user.save() return user logging.error("user login failed: %s" % repr(result)) return None