Skip to content

authentication programmatically #1361

Answered by auglotus
auglotus asked this question in Q&A
Discussion options

You must be logged in to vote

@hgalytoby Thanks for your help again! I found I mistakenly append 'authorization' into headers multiple times.

I summary the final solution below:

  1. Config FastAPI-Users into NiceGUI following the official doc.

  2. We need customize programmatically call functions (outside the dependency injection mechanism):

get_async_session_context = contextlib.asynccontextmanager(get_async_session)
get_user_db_context = contextlib.asynccontextmanager(get_user_db)
get_user_manager_context = contextlib.asynccontextmanager(get_user_manager)

async def user_authenticate(email: str, password: str) -> Optional[User]:
    try:
        async with get_async_session_context() as session:
            async with…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@auglotus
Comment options

@auglotus
Comment options

@hgalytoby
Comment options

@auglotus
Comment options

Answer selected by auglotus
@MaiHoangViet1809
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants