mauriciovigolo / keycloak-angular

Easy Keycloak setup for Angular applications.
MIT License
730 stars 280 forks source link

Add setup instructions for standalone bootstrap #560

Open TDesjardins opened 6 months ago

TDesjardins commented 6 months ago

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search for issues before submitting
- [x] feature request

Desired functionality.

The current setup instructions in readme.md only cover the NgModules approach. It would be useful to also have infos about how to setup a standalone bootstrap / components app.

I could provide a working example but havn't tested the Auth Guard yet.

molntamas commented 2 months ago

@TDesjardins could you provide a working example? Thanks a lot!

mauriciovigolo commented 2 months ago

Hey @molntamas, I'm working to update the documentation and examples. It will be available soonish this or in the following week.

molntamas commented 2 months ago

Hey @molntamas, I'm working to update the documentation and examples. It will be available soonish this or in the following week.

Thank you!

gvinaccia commented 2 weeks ago

Maybe this helps someone:

in order to have the bearerInterceptor working while using the standalone configuration it is necessary to add the withInterceptorsFromDi() feature in provideHttpClient

this is how i got it working

export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(withInterceptorsFromDi()),
    importProvidersFrom([KeycloakAngularModule]),
    {
      provide: APP_INITIALIZER,
      useFactory: initializeKeycloak,
      multi: true,
      deps: [KeycloakService],
    },
};