Sample application and SDK integration Similar to the Okta APIs, the SDK uses a generic interface to handle each step of the user sign-in flow. This interface enables apps to use a dynamic model when responding to policy changes within Okta. Specifically, it enables a policy-driven design that accepts new functionality, such as adding other sign-in factors, without the need to update your app's code. This feature is important for mobile devices due to the challenges in updating apps. See how the sample app uses the SDK to implement this dynamic policy-driven behavior.
Integrate the SDK with the sample code The sample code (opens new window) provided in this step-by-step guide wraps the SDK with a more prescriptive and explicit interface. This sample code is designed to help you understand how to use the SDK. Although you can implement similar code in your app, you're advised to use the best practice approach that's implemented in the sample app (opens new window) .
The following steps document how to integrate the sample code into your app. The sample code converts the SDK's generic remediation interface into explicit authentication steps and automatically executes steps, such as the code-to-token exchange. The following diagram illustrates this call flow from your app's UI to the sample code, SDK, and API.
Note: The integrating code component represents the code that you write to call the sample code's interface.
Launch the app and initialize the SDK The first step is to initialize the SDK when the user opens your app. This is done by creating an instance of BasicLogin
and passing into its initializer a configuration
object.
For more information on how to set the configuration parameters, see SDK in Download and set up the SDK, Sign-In Widget, and sample app .
The user initiates the sign-in flow When the user enters their credentials and initiates the sign-in flow, call the login
method, passing in the username, password, and completion
closure. This closure is invoked after the sign-in process completes and returns either a fatal error or a success status with a token.
Send the user to the home page after a successful sign-in flow The final integration step is to send the user to the default home page after a successful sign-in flow. Optionally, you can obtain basic user information after the user successfully signs in by making a request to the Okta OpenID Connect authorization server. See Get the user profile information .
Sample code The following sample code is also in the okta-idx-swift repository (opens new window) .