GUI application before session starts

Hi friends!
I have a project I’m working on, where I want to enable an MFA for user login.
Basically what I’m trying to achieve it for my PAM module to populate GUI window after the user enters his password, and having some challenges in said GUI (to be approved by the PAM module)
But no matter what I do, I can’t seem to open a GUI of some sort.
I’ve tried -
Manipulating the GDM PreSession/PostLogin
Creating a GTK GUI binary
Running zenity
Creating a gnome extension
Manipulatin Autostart Configuration with a .desktop file

No matter what I try, it seems that I am unable to open the display, and indeed, looking into the /tmp/.X11-unix directory, the 0 display shows only after the desktop starts.
I keep getting “Failed to open display”

I’m running Ubuntu 24.04, Gnome Shell 46.0

(For refferance my end goal is to do something like Ubuntu authd does


)
But creating a full screen web-browser-like window would also be great.

Would appreciate you help/direction to what I’m missing

Yeah what you’re trying to do isn’t really possible. PAM is running in a completely different environment (as root) and no GUI can be available there.

Anyway, if you’re trying to emulate authd you should do what authd does. The PAM module speaks via a custom GDM PAM extension to send JSON through GDM into gnome-shell. Then custom UI in GNOME Shell displays this prompt.