Django Custom Auth Backend (Web Service, No DB): How to Store Data in Session?

How can I save a token in a custom Django web-service auth backend (without a database) when the request object isn’t available?

def check_external_identity(user, pwd):
    token_val = external_verify(user, pwd)
    return {'user_id': user} if token_val else None

you cant store token directly here; try passin it back and then write a middleware or view that handles session device where request is available. it’s a workaround but shows how to decouple the auth backend from direct session access.