-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: Async provider loader with provideAuth #1971
Comments
I am experiencing the same problem. Due to business requirements, I need to load the OIDC configuration from an API. It worked with the HTTP loader in the old module implementation, but since upgrading to Angular 18, I cannot find a solution to use an async loader with |
You should be able to do it like this: provideAuth({
loader: {
provide: StsConfigLoader,
useFactory: httpLoaderFactory, // 👈 your implementation to get the config
}
}),
// Example implementation:
export const httpLoaderFactory = (): StsConfigLoader => {
const httpClient = inject(HttpClient)
const config$ = httpClient
.get<any>(
`https://offeringsolutions-sts.azurewebsites.net/api/ClientAppSettings`
)
.pipe(
map((customConfig: any) => {
return {
authority: customConfig.stsServer,
redirectUrl: customConfig.redirect_url,
clientId: customConfig.client_id,
responseType: customConfig.response_type,
scope: customConfig.scope,
postLogoutRedirectUri: customConfig.post_logout_redirect_uri,
startCheckSession: customConfig.start_checksession,
silentRenew: customConfig.silent_renew,
silentRenewUrl: customConfig.redirect_url + '/silent-renew.html',
postLoginRoute: customConfig.startup_route,
forbiddenRoute: customConfig.forbidden_route,
unauthorizedRoute: customConfig.unauthorized_route,
logLevel: LogLevel.Debug,
maxIdTokenIatOffsetAllowedInSeconds:
customConfig.max_id_token_iat_offset_allowed_in_seconds,
historyCleanupOff: true,
// autoUserInfo: false,
};
})
);
return new StsConfigHttpLoader(config$);
}; |
It works well ! Thanks for your help @timdeschryver ! I close this issue PS: My problem was the call of useFactory as an arrow function. |
What Version of the library are you using?
Working with Angular 18+ and "angular-auth-oidc-client": "18.0.0",
...
Question
How can I implement the loader factory "provideAuth" with Angular 18 please ?
Here is my
app.config.ts
And the config loader:
I followed the exemple here: https://statics.teams.cdn.office.net/evergreen-assets/safelinks/1/atp-safelinks.html
For an implementation with a static config. It works well with it but not when it comes with a loader.
I need to load the config dynamically and asynchronously.
Thanks for your help !
The text was updated successfully, but these errors were encountered: