Accessing multiple erpnext instances using a single authentication provider

My company requires me to implement two separate ErpNext instances for different purposes.
But we want an OAuth authentication provider of our own to act as a third-party authentication provider for both instances and restrict other ways of authentication. The OAuth provider would be possibly implemented in FastAPI.
How can I achieve this?