Hi Garth,
AuthenticationFlowError = Java.type("org.keycloak.authentication.AuthenticationFlowError");
function authenticate(context) {
  LOG.info(
script.name + " --> trace authenticate for: " + user.username);
  context.attempted();
Â
}
function configuredFor(session, realm, user) {
  LOG.info(
script.name + " --> trace configuredFor for: " + user.username);
  return false;
}
function setRequiredActions(session, realm, user) {
  LOG.info(
script.name + " --> trace setRequiredActions for: " + user.username);
  user.addRequiredAction("select_organisation");
}
I have the script set up, and the provider added to the flow.
However, following username/pwd auth, the user gets an error about invalid username and password.
The logs show:
2021-05-18 13:17:56,492 ERROR [stderr] (default task-36) Warning: Nashorn engine is planned to be removed from a future JDK release
2021-05-18 13:17:56,938 INFO Â [org.keycloak.authentication.authenticators.browser.ScriptBasedAuthenticator] (default task-36) Select Organisation Authenticator --> trace authenticate for: test
2021-05-18 13:17:56,947 WARN Â [org.keycloak.services] (default task-36) KC-SERVICES0013: Failed authentication: org.keycloak.authentication.AuthenticationFlowException
    at org.keycloak.ke...@12.0.4//org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:943)
    at org.keycloak.ke...@12.0.4//org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:311)
    at org.keycloak.ke...@12.0.4//org.keycloak.services.resources.LoginActionsService.processAuthentication(LoginActionsService.java:282)
    at org.keycloak.ke...@12.0.4//org.keycloak.services.resources.LoginActionsService.authenticate(LoginActionsService.java:266)
    at org.keycloak.ke...@12.0.4//org.keycloak.services.resources.LoginActionsService.authenticateForm(LoginActionsService.java:339)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
So it looks like the script is getting hit, but I'm really struggling to work out why it is erroring.