Skip to content

Latest commit

 

History

History

angular

README.md

Phase Two Angular example: angular-oauth2-oidc

🚀 View the deployed example

An Angular 22 app (standalone components, signals, no zone.js) that logs users in with Keycloak using the authorization code flow with PKCE, through angular-oauth2-oidc. It is styled with Tailwind CSS.

Tokens are kept in session storage and refreshed before they expire. Logging out also ends the Keycloak session.

Configuration

File Used by Keycloak
src/environments/environment.ts production builds (pnpm build, Vercel) the hosted Phase Two demo realm https://app.phasetwo.io/auth/realms/p2examples
src/environments/environment.development.ts pnpm start the local Keycloak http://localhost:8080/auth/realms/p2examples

Both use the public client angular. For your own realm, create an OpenID Connect client with client authentication off, the standard flow enabled, http://localhost:4200/* as valid redirect URI, and + as web origin and as valid post logout redirect URI, then change the environment files.

Run it

Start the local Keycloak first, then:

pnpm install
pnpm start

Open http://localhost:4200 and log in as demo / demo. pnpm build creates a production build in dist/angular/browser. pnpm test, pnpm lint and pnpm format are also available.