Generalized the auth flow