Hi! I’m trying to create on my application a login page using javascript adapter and curl php for user authentication on sso. I’m using version 6.0 of keycloak.
I created a client (both with client secret and without), I call sso_server/auth/realms/test/protocol/openid-connect/token with:
grant_type=password
client_id=myclientid
username=pippo
password=passwordpippo
I receive refresh token that I use for to call again sso_server/auth/realms/test/protocol/openid-connect/token with:
grant_type=refresh_token
client_id=myclientid
refresh_token=refreshtokenobtained
but I receive the same above information and not an authorization code though I see in the event listener the user is logged.
The second procedure well works for the logout.
But, when I call the javascript library keycloak.init({onLoad: ‘check-sso’}) the response is “not authenticated”.
How can I use this library for management login page without using keycloak form?
Thanks in advance!
What you are trying to achieve is not recommended. What you are trying to do is less secure than using a redirect. You will not be able to support additional authentication mechanisms like social login, webauthn, otp, etc. You will not have support for SSO, in fact users will (unless you save tokens to local storage/cookie which we wouldn’t recommend) have to re-login on each page reload.
If you want to create a custom login screen you should do that with a custom theme. That will allow you to customise it as much as you want ranging from custom CSS, custom templates/html all the way up to custom authentication flows with custom authenticators.
Hi,
I am having the same issue, i would like to do the login from my site without the redirection… is it possible? Is there an example.of how to login and register with api and withour redirect?
Thanks
I’m aware that this is less sure than to use the redirect but I need it. I think that the main problem is to manage cookies and session: I don’t understand how keycloak manages those
Hi,
We need our own login\registration page too. We need to modify login\registration page for our clients that are having their own clients(end user). Keycloak provide Themes, but they are not so flexible and easy to manage as a custom page with web Administration panel.