// Sign in with CodeB - Angular (angular-oauth2-oidc). // European Digital Identity Wallet users can also arrive via /logineu.html. // [oidc-signin-cookbook 2026-07-23] // npm install angular-oauth2-oidc import { Component, OnInit } from '@angular/core'; import { AuthConfig, OAuthService } from 'angular-oauth2-oidc'; export const authConfig: AuthConfig = { issuer: 'https://', clientId: '', redirectUri: '', responseType: 'code', scope: 'openid profile email', showDebugInformation: false, // PKCE (S256) is on by default in angular-oauth2-oidc. // Discovery -> https:///.well-known/openid-configuration }; @Component({ selector: 'app-signin', template: `
Signed in as {{name}} (role={{role}})
` }) export class SignInComponent implements OnInit { signedIn = false; name = ''; role = ''; constructor(private oauth: OAuthService){ this.oauth.configure(authConfig); } async ngOnInit(){ await this.oauth.loadDiscoveryDocumentAndTryLogin(); if (this.oauth.hasValidAccessToken()){ const c: any = this.oauth.getIdentityClaims(); this.signedIn = true; this.name = c.preferred_username; this.role = c.role || 'user'; } } login() { this.oauth.initCodeFlow(); } logout() { this.oauth.logOut(); } }