Skip to main content

OAuth2

· One min read

Open in Notion

Let’s see how this Oauth2 workflow looks like:

Untitled.png

Untitled.png

SSO/OAuth2.0

link_preview

$ 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();