2

I am integrating Dart with Keycloak. I have included keycloak.js ( https://github.com/keycloak/keycloak-js-bower/blob/master/dist/keycloak.js ) in index.html.

Dart class :

@JS()
library  keycloak11;

import 'package:js/js.dart';

@JS('Keycloak')
class Keycloak1 {
  external  init(InitOptions opts);
  external Keycloak1();
}



@JS()
@anonymous
class InitOptions {
  external String get onLoad;
  external set onLoad(String v);

  external factory InitOptions({
    String onLoad
  });
}



    in  onActivate()  of  the  page -

     var kcl = new Keycloak1();
     var promise =  kcl.init(new InitOptions(onLoad :  'login-required'));

This takes me to the login page fine. How can I register success and error callbacks ?

In javascript, this works -

 keycloak.init({onLoad: 'login-required'}).success(function (authenticated) {
            if (!authenticated) {
                alert('not authenticated');
            } else {
                alert('success');
            }

        }).error(function () {
            alert('failed to initialize');
        });
1

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.