Skip to main content
The Dynamic Flutter SDK provides email and SMS authentication through OTP (One-Time Password) verification. Users can sign in by receiving a verification code sent to their email address or phone number.
Email and SMS authentication must be enabled in your environment’s dashboard settings before they can be used in your application.
If users report delayed or missing OTP emails, see the Email OTP delivery troubleshooting guide.

Email Authentication

Send Email OTP

Send a verification code to the user’s email address:

Verify Email OTP

Verify the OTP code entered by the user:

Resend Email OTP

Allow users to request a new OTP code if the previous one expired or wasn’t received:

Rate Limits

Email verification is subject to the following rate limits:
  • 3 attempts per 10 minutes per email address
This is in place to protect deliverability of emails and to prevent abuse.

SMS Authentication

Send SMS OTP

Send a verification code to the user’s phone number using the PhoneData structure:

Verify SMS OTP

Verify the OTP code entered by the user:

Resend SMS OTP

Allow users to request a new OTP code:

PhoneData Structure

The SMS authentication methods use a PhoneData object that contains:
  • dialCode: The country dial code (e.g., “+1” for US, “+44” for UK)
  • iso2: The two-letter country code (e.g., “US”, “GB”, “JP”)
  • phone: The phone number without the country code
Examples:

External JWT Authentication

For apps with existing authentication systems, you can authenticate users with an external JWT:

Authentication State

Check Current User

Listen for Authentication Changes

Use streams to react to authentication state changes:

Logout

Built-in UI

The easiest way to add authentication is using the built-in UI which handles all authentication methods:

Complete Authentication Flow

Here’s a complete example combining email and SMS authentication:

Configuration

Dashboard Settings

Configure email and SMS authentication in your Dynamic dashboard:
  1. Enable Email Authentication:
    • Go to Login & User Profile
    • Toggle “Email” on to enable email authentication
    • No additional configuration is required
  2. Enable SMS Authentication:
    • Go to Login & User Profile
    • Toggle “SMS” on to enable SMS authentication
    • You can optionally provide your own SMS provider credentials in the phone number settings
    • This is required for phone numbers outside of US and Canada

Best Practices

1. Error Handling

Always handle errors gracefully and provide clear feedback to users:

2. User Experience

  • Show loading states during authentication
  • Provide clear error messages
  • Allow users to resend OTP if needed
  • Display the email/phone where OTP was sent
  • Add countdown timer for resend button

3. Security

  • Never store OTP codes
  • Always use HTTPS connections
  • Implement proper session management
  • Handle token refresh automatically

Troubleshooting

OTP Not Received

  • Check that the email/phone number is valid
  • Look in spam folder for email OTP
  • Verify that the provider is enabled in Dynamic dashboard
  • Check rate limits haven’t been exceeded

Authentication Fails

  • Ensure OTP code is entered correctly
  • Check that the code hasn’t expired (codes typically expire after 10 minutes)
  • Verify network connectivity
  • Check for any error messages in logs

Session Not Persisting

  • Ensure you’re listening to tokenChanges or authenticatedUserChanges streams
  • Verify that the SDK is properly initialized
  • Check that you’re not clearing app data
  • Make sure the DynamicSDK.instance.dynamicWidget is included in your widget tree

What’s Next

Now that you have authentication set up:
  1. Social Authentication - Add social login options
  2. Session Management - Manage authenticated sessions with Streams
  3. Wallet Creation - Learn about automatic wallet creation
  4. Wallet Operations - Work with user wallets

Reference

For more details on the authentication API, see:
Last modified on March 4, 2026