Implementing custom 2FA in Retool Custom Auth – Issues with JSON Parsing

We’re trying to integrate our backend’s 2FA system into Retool’s Custom Authentication workflow but have encountered a few blockers:

  1. No Conditional Modal Logic – We need to show a 2FA prompt based on a boolean response from our backend, but there’s no built-in way to conditionally trigger a modal within the Custom Auth workflow.
  2. Workaround Approach – To bypass this, we are using a REST API component to call our login endpoint, retrieve authentication tokens, and then manually paste the response JSON into a text field within the Custom Auth workflow. The expected JSON structure looks like this:

{
"response": {
"token": "",
"refreshToken": "",
"deviceToken": ""
}
}

  1. Issue with Parsing – However, when trying to reference or parse the pasted JSON within a JS component inside the Custom Auth workflow, we consistently get an internal server error.

We’d appreciate any guidance on resolving this issue, whether it involves troubleshooting the current approach or exploring a better way to integrate 2FA with our backend.

Thanks in advance for your help!

Hey @Marco_Joynt - welcome to the community!

In the shorter term, I think it would be worthwhile to look at your current implementation and see if we can figure out what's going on. Have you verified the response from the API Request step? It would be helpful to see the contents of the JS step and the specific error messages, as well.

In the longer term, our team here would probably be receptive to enabling conditional logic in custom authentication flows. I'll document that request internally and provide an update here as soon there is news to share. :+1:

Hey @Marco_Joynt - I don't have any significant update as far as enabling conditional logic is concerned, but wanted to check in and see if you can share more context about your current implementation. It sounds like a valid workaround, so I'm curious to figure out the issue that you're describing.