Not receiving response from VerifyFactor

Not sure why I am not getting a response back from the OKTA Verify code. I do get the notification on my phone and I acknowledge, but then I never exit the
VerifyFactor function – since it never get’s an acknowledgement. Any ideas? Is there something in OKTA that needs to be set? Am I not calling the AWAIT correctly?

Using .Net framework 4.8.x and OKTA SDK 2.x

Public Async Function AuthenticateWithMFA(susername As String, spassword As String) As Task
Try
’ Initialize the Okta client
Dim oktaClient = New AuthenticationClient(New OktaClientConfiguration With {
.OktaDomain = OktaDomain,
.Token = APIToken
})

        ' Authenticate the user with username and password
        Dim authnOptions = New AuthenticateOptions() With {
                .Username = susername,
                .Password = spassword,
                .MultiOptionalFactorEnroll = True,
                .WarnBeforePasswordExpired = True
        }

        Dim authResponse = oktaClient.AuthenticateAsync(authnOptions).Result
        LogMessage("AuthenticationStatus: " & authResponse.AuthenticationStatus.ToString)

        If authResponse.AuthenticationStatus = "MFA_REQUIRED" Then

            ' MFA is required, check for available factors
            Dim allFactors As Okta.Sdk.Abstractions.CastingListAdapter(Of Factor) = authResponse.Embedded.GetArrayProperty(Of Factor)("factors")

            ' Find Okta Verify Push factor
            Dim oktaVerifyPushFactor = allFactors.FirstOrDefault(Function(f) f.Type.Contains("push"))

            Dim factorID = oktaVerifyPushFactor.Id
            LogMessage("FactorID: " & factorID.ToString)

            If factorID IsNot Nothing Then
                Dim stateToken As String = authResponse.StateToken

                ' Set options based on your MFA method (e.g., SMS, Okta Verify, etc.)
                Dim verifyFactorOptions = New VerifyPushFactorOptions() With
                {
                    .FactorId = factorID,
                    .StateToken = stateToken,
                    .AutoPush = True,
                    .RememberDevice = True
                }

                LogMessage("Ready to call VerifyFactor  ")
                ' Verify MFA factor
                Dim mfaResponse = Await VerifyFactor(oktaClient, verifyFactorOptions)
                LogMessage("mfaResponse.AuthenticationStatus  " & mfaResponse.AuthenticationStatus.ToString)

                If mfaResponse.AuthenticationStatus = "SUCCESS" Then
                    LogMessage("MFA verification succeeded")
                Else
                    LogMessage("MFA verification failed")
                End If
            Else
                LogMessage("No suitable MFA factor found")
            End If
        ElseIf authResponse.AuthenticationStatus = "SUCCESS" Then
            LogMessage("Authentication succeeded without MFA")
        Else
            LogMessage($"Authentication failed. Status: {authResponse.AuthenticationStatus}")
        End If
    Catch ex As Exception
        LogMessage($"Exception: {ex.ToString()}")
    End Try
End Function

Private Async Function VerifyFactor(client, options) As Task(Of AuthenticationResponse)
    ' Perform MFA factor verification
    Return Await client.VerifyFactorAsync(options)
End Function

Hi @gmcdanl,

Can you try with the latest Okta .net SDK 7.0.3?
You could verify the factor with the userId and the factorId.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.