Comments (4)
Hello @CodeBenson,
Sure we can help! So this is probably related to the initOptions you passed in the keycloak initialization. If you followed the examples in the README.md, the initOptions.onLoad has a value === 'login-required'. This value in the keycloak-js library, redirects the user to the login page.
Look at the example below:
await keycloak.init({
config: {
url: 'http://localhost:8080/auth',
realm: 'your-realm',
clientId: 'client-id'
},
initOptions: {
onLoad: 'login-required', // redirects to the login page
checkLoginIframe: false
},
bearerExcludedUrls: [
'/assets',
'/clients/public'
],
});
resolve();
} catch (error) {}
In your case, the problem is related to this configuration or with the auth guard.
From the keycloak javascript adapter documentation:
By default to authenticate you need to call the login function. However, there are two options available to make the adapter automatically authenticate. You can pass login-required or check-sso to the init function. login-required will authenticate the client if the user is logged-in to Keycloak or display the login page if not. check-sso will only authenticate the client if the user is already logged-in, if the user is not logged-in the browser will be redirected back to the application and remain unauthenticated.
Try to change this value and also take a look at your routes, if the landing page has an auth guard configured. If it has an auth guard (the landing page), try to remove it.
Thanks!
from keycloak-angular.
Yeah sure, sorry should have told you. It worked with setting 'login-required' to 'check-sso'. Thanks again! 👍
from keycloak-angular.
@CodeBenson,
Will close this issue, since it seems to be ok. If you have any other doubts you can also use our slack at: keycloak-angular.slack.com .
See you there!
from keycloak-angular.
Is it possible to use a string in this form?
const str = JSON.stringify( {
"realm": "test",
"auth-server-url": "http://localhost:8080/auth",
"ssl-required": "external",
"resource": "test",
"public-client": true,
"confidential-port": 0
});
await keycloak.init({
config: str ,
initOptions: {
onLoad: 'login-required', // redirects to the login page
checkLoginIframe: false
},
bearerExcludedUrls: [
'/assets',
'/clients/public'
],
});
resolve();
} catch (error) {}
I get an error "GET http://localhost:4200/%7B%22realm%22:%22test%22,%22auth-server-url%22:%22http://localhost:8080/auth%22,%22ssl-required%22:%22external%22,%22resource%22:%22test%22,%22public-client%22:true,%22confidential-port%22:0%7D 404 (Not Found)" and "ERROR An error happened during Keycloak initialization."
kind of like config allows : "config?: string | KeycloakConfig;"
from keycloak-angular.
Related Issues (20)
- Angular v.17 update HOT 5
- KeycloakService#getUserRoles() filter by resource HOT 2
- Loop after keycloak redirect to angular website HOT 6
- Support for Pure Function-Based Guards in Angular HOT 2
- Support for Keycloak v23 HOT 9
- The JSDoc for getToken states it calls updateToken if necessary, but it does not HOT 1
- How I would know when the session is expired? HOT 1
- Problem with KeycloakService in Angular 17 HOT 1
- KeycloakAuthGuard example HOT 4
- Server-side rendering (SSR) crash with 'Document not found' error in Keycloak-angular with Angular 17 HOT 10
- keycloakBearerInterceptorFn example HOT 1
- Login method locale is not changing the user locale when the user logs in
- angular crashes with check-sso
- Support KC 24.x.x HOT 6
- Catch sign out event or redirect to ssop event
- keycloak-angular - next version improvements HOT 1
- Bug in package.json version 15.2.0 HOT 3
- Keycloak setup for Single SPA angular Project
- HttpClient Interceptor not working HOT 1
- Configure updateToken minValidity in HTTP Interceptor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keycloak-angular.