I’m trying to integrate an Azure AD sign in method with a Reflex app. The MSAL python library provides a broker service to allow interactive sign ins in a windows environment, but requires a window handle to target. It’s inside a docker container, which rules out pywin32 for grabbing the active window.
My question:
Does Reflex provide a way to get its window handle? Pywin32’s equivalent is:
I copied the docs example, which runs normally. When I add in an identical section for the window.getCurrent, it doesn’t return anything and I end up with “{}” in the text box. I’ve also tried lastFocusedWindow, but it’s the same. I know nothing about Javascript or what I could be doing wrong with the script other than mimicking the docs. Would you be able to tell me where to fix this?
In JavaScript, there is no direct window.getCurrent function to retrieve the window handle; window.getCurrent is likely a placeholder that may not actually work as you expect. In web environments, the concept of a “window handle” isn’t directly accessible like it is in native applications.
def get_client_values(self):
return [
rx.call_script(
"window.location.href", # This returns the current URL
callback=WindowState.update_location,
),
rx.call_script(
"[window.scrollX, window.scrollY]", # Returns current scroll positions
callback=WindowState.update_scroll_position,
),
rx.call_script(
"document.title", # Example to return page title instead of window handle
callback=WindowState.update_handle,
),
]
If you are trying to get the hwnd from a client, i can tell you this wont be an easy progress. Server side this is no Problem but Java script is limited to the browser, pretty hard to escape from there and check the whole computers env for the current active window.