0.0.1 • Published 4 months ago
@yaagoub/keycloak v0.0.1
keycloak
Step 1: Import Modules and Services
In your app.config.ts file, import the necessary modules to set up OAuth2:
import {
YgbInterceptor,
YgbKeycloakModule,
YgbKeycloakSettings,
} from '@yaagoub/keycloak';
import { provideHttpClient } from '@angular/common/http';
Step 2: Define OAuth2 Configuration
Create a configuration object that contains all necessary endpoints and credentials for integration:
export interface YgbKeycloakSettings {
secret: string;
// ---------payload token settings--------------
validatePayloadToken?: {
audience?: string,
issuer?: string,
}
// ---------keycloak settings--------------------
loginRedirectUri: string;
logoutRedirectUri: string;
clientId: string;
realmUrl: string;
scope: string;
}
Step 3: Add Configuration to Providers
Add the configuration to the providers array in app.config.ts to make it available throughout the application:
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(appRoutes),
provideHttpClient(withInterceptors([YgbInterceptor])),
...YgbKeycloakModule.forRoot(environment.ygbOAuth2Config as YgbKeycloakSettings),
provideAnimationsAsync()
],
};
0.0.1
4 months ago