How can I get value from client script node

This topic has 1 reply, 2 voices, and was last updated 2 years, 11 months ago by James Phillpotts.

  • Author
  • #24804

    I have created client auth tree node with below code

    @Node.Metadata(outcomeProvider = SingleOutcomeNode.OutcomeProvider.class, configClass = ClientScriptGetTokenNode.Config.class)
    public class ClientScriptGetTokenNode extends SingleOutcomeNode {
    	private final Config config;
    	private final static String DEBUG_FILE = "ScriptedClientNode";
    	protected Debug debug = Debug.getInstance(DEBUG_FILE);
    	public interface Config {
    		@Attribute(order = 100)
    		ScriptConfiguration script();
    		@Attribute(order = 200)
    		String scriptResult();
    	public ClientScriptGetTokenNode(@Assisted Config config) throws NodeProcessException {
    		this.config = config;
    	public Action process(TreeContext context) throws NodeProcessException {
    		Optional<String> result = context.getCallback(HiddenValueCallback.class).map(HiddenValueCallback::getValue)
    				.filter(scriptOutput -> !Strings.isNullOrEmpty(scriptOutput));
    		if (result.isPresent()) {
    			JsonValue newSharedState = context.sharedState.copy();
    			newSharedState.put(config.scriptResult(), result.get());
    			System.out.println(">>>>>>>>>>>>>>>>>>>>>>>"+config.scriptResult() +">>>>"+result.get());
    			debug.message("[" + this.getClass().getSimpleName() + "]" + "Client result is:\n" + result.get());
    			return goToNext().replaceSharedState(newSharedState).build();
    		} else {
    			String clientSideScript = config.script().getScript();
    			debug.message("[" + this.getClass().getSimpleName() + "] " + "Client script is:\n" + clientSideScript + "\n"
    					+ "Client result name: " + config.scriptResult());
    			ScriptTextOutputCallback scriptCallback = new ScriptTextOutputCallback(clientSideScript);
    			HiddenValueCallback hiddenValueCallback = new HiddenValueCallback(config.scriptResult());
    			ImmutableList<Callback> callbacks = ImmutableList.of(scriptCallback, hiddenValueCallback);
    			return send(callbacks).build();

    Client Script


    How Can I get ssoToken value from result.get()


    To obtain a value from the browser, you would need to use the DOM API to set the value of the hidden <input.../> element for the hidden input callback, which will have an id of something like IDToken2, and then trigger submission of the page.


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?