I'm implementing a chatbot with Chainlit running as a subsystem within a FastAPI application.
The chatbot app is a provider tool and is launched from Moodle (consumer) based on LTI standard.
I'm a little desperate because I don't know the way to get the headers or URL parameters in the authentication header hook. Currently, we cannot find a way for Chainlit to properly receive and process this data when running under FastAPI.
try:
launch.validate_required_parameters()
except ParametersValidationException as ex:
return close_window_response("Faltan parámetros requeridos en la solicitud")
if not launch.validate_signature():
return close_window_response("Firma OAuth inválida. Cerrando ventana...")
session_id = str(uuid.uuid4())
user_session = UserSession(
id=session_id,
user_id=launch.data["user_id"],
payload=json.dumps({
"username": launch.data.get("ext_user_username"),
"name": launch.data.get("lis_person_name_given"),
"surname": launch.data.get("lis_person_name_given"),
"roles": launch.data.get("roles"),
"context_id": launch.data.get("context_id")
})
)
store_session(user_session)
return RedirectResponse(url=f"/chat?session_id={session_id}", status_code=303)
mount_chainlit(app=app, target="chat/chatbot.py", path="/chat")
Steps to reproduce the behavior:
- Go to Moodle and launch the external tool endpoint (chatbot).
- If the Oauth validation is successful, the FastAPI application redirects to the chatbot (Chainlit subsystem) with the nonce token as a URL parameter (session_id).
- The @cl.header_auth_callback doesn't receive custom parameters or headers. At this point, I need the user data (headers or query params) to reach the Chainlit environment in order to personalize the session, but they are not being received.
I'm using chailit 2.5.7
Thanks in advance.
I'm implementing a chatbot with Chainlit running as a subsystem within a FastAPI application.
The chatbot app is a provider tool and is launched from Moodle (consumer) based on LTI standard.
I'm a little desperate because I don't know the way to get the headers or URL parameters in the authentication header hook. Currently, we cannot find a way for Chainlit to properly receive and process this data when running under FastAPI.
Steps to reproduce the behavior:
I'm using chailit 2.5.7
Thanks in advance.