I'm trying out keycloak with angular 2. I'm making a service where I do as they do in their doc. However it always returns not authenticated
even though I'm connected when I connect to my account keycloak url (auth/realms/wb/account
).
declare var Keycloak: any;
@Injectable()
export class UserMockService {
constructor() {
let keycloak: any = new Keycloak('assets/keycloak.json');
keycloak.init().success(function(authenticated) {
alert(authenticated ? 'authenticated' : 'not authenticated');
}).error(function() {
alert('failed to initialize');
});
}
}
Yes it does find the json.
{
"realm": "wb",
"auth-server-url": "http://192.168.99.100/auth",
"ssl-required": "external",
"resource": "wb",
"public-client": true
}
Oh yeah and before I forget: what the heck is the URL to redirect user to connect to my app ? Seems like it should be something easy to find but their doc is so scattered.. To connect at the moment I use /auth/realms/wb/account but that's the url to connect to the account settings..
So the flow is like this :
http://192.168.99.100/auth/realms/wb/account
.I can recommend having a look into the official Angular 2 client app example on the Keycloak GitHub.
A month ago, I successfully created a Keycloak secured Angular 2 app using the snippets out of this example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With