[keycloak-user] keycloak and angular

Juan Diego juandiego83 at gmail.com
Thu Jun 11 16:51:10 EDT 2015


Hi,

I was looking at the angular product app in the demos.  And I am trying
having some issues, if you use it with angular 1.3 it says that
responseInterceptors  are deprecated, but I got around that.

I am not using

angular.element(document).ready() and
keycloakAuth.init({ onLoad: 'login-required' })

like in the example because I want my users to click on a login
button.  So I have a function like this

var login = function () {
    keycloakAuth.login();
}

I also have a init() function that is like this:
var init = function(){
    auth.loggedIn = false;

    keycloakAuth.init().success(function(authenticated) {
        if(authenticated ){
            auth.loggedIn = true;
            //auth.authz = keycloakAuth;
        }else{
            auth.loggedIn = false;
        }
        console.log('Init Autenticado ' +auth.loggedIn );
    }).error(function() {
        console.log('failed to initialize');
        auth.loggedIn = false;
    });

}

And I call it on my script at the end.

And it seems to work.  But I am trying to do 2 things, save the token
and use angular.  I know javascript but I am just starting with
angular.

So here I have some questions.

In the angular example is the 'authInterceptor' supposed to replace
onAuthSuccess callback.  Or am I wrong.
Using angular how should I talk the callback listeners

Second part, is that in the "authInterceptor" I am getting
Auth.authz.token as undefined, but in my console.log I can see it.

So apparently console.log gets executed after a while, so that is why
i can see the token on console.log, but authz.token is undefined
aparently.

Maybe I am wrong with my logic, so here is what I think are the basic
parts of using keycloak.js.
Should I use document ready and remove ng-app on my page for keycloak to work

thanks,

Juan Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150611/cce36447/attachment.html 


More information about the keycloak-user mailing list