Learn
Learn how the Okto Onboarding Modal helps streamline user authentication and onboarding workflows in Flutter apps.
What is the Onboarding Modal?
Okto’s Onboarding Modal provides a streamlined way to authenticate users by displaying an embeddable flow (via a WebView) without requiring them to leave your Flutter app. Under the hood, the Onboarding Modal can handle multiple authentication flows (Email OTP, Phone OTP, Google OAuth, etc.) and can be customized with brand data, visuals, and theming.
Why Use the Onboarding Modal?
-
No Authentication Flow Management
Vendors need not work or worry about the authentication flow or the code for it. Okto handles everything on the server side, simplifying the implementation and saving development time. -
Multi-Auth Support
The modal can be set up to handle Google Auth, Email OTP, Phone OTP, or your primary authentication of choice. -
Brand & Theme Customizations
Pass your branding (title, subtitle, icon) and theming (colors, backgrounds, etc.) to tailor the onboarding experience to your style guidelines.
Typical Flow
Below is a simplified sequence for how the Onboarding Modal works:
-
Trigger the Modal
Your Flutter code callsokto.openOnboarding(...)
from the Okto SDK. This opens a new Onboarding page containing a WebView. -
WebView Initialization
The WebView loads the Okto environment for your selectedbuildType
(Sandbox, Staging, or Production).
It also receives your brand data, theming, and selected primary authentication method. -
User Authentication
The user completes the steps (e.g., Google login, Email OTP, or Phone OTP). If the flow requires an external token (like a Google ID token), Okto can request it from your Flutter app viagAuthCallback()
. -
Auth Success
Once the user is authenticated, Okto returns the relevant tokens (authToken
,refreshToken
, etc.) and closes the onboarding screen automatically. At that point, your Flutter app can continue with a fully authenticated user.
Sequence Diagram
Key Points to Remember
showOnboardingModal()
in the SDK is your main entry point to launch the modal.- You can customize brand data, theming, and the primary auth method (Email, Phone, or Google).
- For Google OAuth, provide a callback (
gAuthCallback
) that returns an ID token from your chosen sign-in flow (e.g.,google_sign_in
package). - On success, your app will have the user’s
authToken
(and refresh token) stored in Okto’s internal state.
Enabling Google Authentication in the Onboarding Modal
Okto’s Onboarding Modal can integrate with Google Authentication to offer a smooth, single-click login experience. To enable this, you need to configure the gAuthCallback
, which handles the retrieval of your Google ID token. Below is an example using the google_sign_in
package.
Example login_page.dart
snippet:
Key Steps:
- The callback
_loginWithGoogle
returns a Google ID token (or empty on error). - Okto uses this token to complete the Google auth process.
- On success,
onLoginSuccess
is called, and your user is now fully authenticated.
Common Tips & FAQ
-
Custom Branding: Okto’s
openOnboarding(...)
lets you passtitle
,subtitle
,iconUrl
plus color theming to customize the look. -
Primary Auth Method: By default, you can set
primaryAuth: AuthType.GAuth
(Google),AuthType.EMAIL
, orAuthType.PHONE
. You can also override it dynamically if needed.