Let’s see how this Oauth2 workflow looks like:

SSO/OAuth2.0

https://github.com/authts/oidc-client-ts

$ npm install oidc-client-ts --save
import { UserManager } from "oidc-client-ts";

const mgr = new UserManager({
  authority: "<https://idp.example.com>",
  client_id: "your-client-id",
  redirect_uri: "<https://app.example.com/auth/callback>",
  post_logout_redirect_uri: "<https://app.example.com/>",
  response_type: "code",
  scope: "openid profile email api.read",
});

// Redirect to signin page
await mgr.signinRedirect();

// callback
const user = await mgr.signinRedirectCallback();