I've used it for the exact same thing. I had a "userService" machine (embedded in a React UI) that handled all the legwork of an OAuth2 flow and ended with the user in an "authenticated" state with their details as part of the machine context (for use in any other part of the app via a custom hook).
You are absolutely right, it couldn't be wrong. It always just worked exactly the way it was supposed to.
I'm now working on a project that handles logins via a set of disconnected boolean flags flowing through redux and it is a mess.
I've used it for the exact same thing. I had a "userService" machine (embedded in a React UI) that handled all the legwork of an OAuth2 flow and ended with the user in an "authenticated" state with their details as part of the machine context (for use in any other part of the app via a custom hook).
You are absolutely right, it couldn't be wrong. It always just worked exactly the way it was supposed to.
I'm now working on a project that handles logins via a set of disconnected boolean flags flowing through redux and it is a mess.