Using Okta Java SDK 1.5.4 for MFA

Any ideas on how can I use the Java SDK to setup multi-factor authentication in my app?
I’ve looked through the documentation, I was not able to find anything.
Please suggest any method, with example code if possible.
Thank You.


Do you want multi-factor on the Okta login screen or through your app itself?

Through my app.

AuthenticationClient client = AuthenticationClients.builder()

I am unable to do anything past this point. Now how do I initiate primary authentication?

I found this in the docs

authenticate(String username, char[] password, String relayState, AuthenticationStateHandler stateHandler)

I am not sure what is relayState and stateHandler.

The state handle is this Object (

The relay state is optional so you don’t need to use it yet.

MFA can only be enforced through the Okta login screen unless you build it yourself. To force MFA you will need to set appropriate policies and MFA policies.

I recommend getting familiar with OAuth2 if you struggling to implement it or understand it.

There are flows that allow you to pass username and password however I cannot vouch for mutlifactor.