Getting started overview

SAWO Labs facilitates the integration of passwordless authentication into web and mobile applications. The getting started process involves a few core steps: account creation, application registration to obtain API keys, and then integrating one of SAWO's SDKs to perform an authentication request. The platform supports various development environments, including web, Android, and iOS, with dedicated SDKs to streamline the integration process.

Developers typically begin by creating an account on the SAWO Labs dashboard. Once an account is established, an application can be registered, which generates the necessary API keys and a unique API key for that application. These credentials are then used to initialize a SAWO SDK within the target application. Finally, a method provided by the SDK is invoked to trigger the passwordless authentication flow, such as an OTP-less login or biometric verification, replacing the traditional username and password entry. This approach aims to reduce user friction during login and enhance security by eliminating static passwords.

The following table summarizes the key steps:

Step What to do Where
1. Sign up Create a SAWO Labs developer account. SAWO Labs homepage
2. Register App Add a new application in the SAWO Dashboard to get your API Key. SAWO Labs Dashboard
3. Install SDK Integrate the appropriate SAWO SDK for your platform (e.g., Web, Android, iOS). SAWO Labs documentation portal
4. Configure SDK Initialize the SDK with your API Key and other settings. Your application's codebase
5. Implement Auth Call the SAWO authentication method to initiate passwordless login. Your application's codebase

Create an account and get keys

To begin using SAWO Labs, developers must first create a free account. This account provides access to the SAWO Labs Dashboard, where applications are managed and API keys are generated. The free tier supports up to 250 monthly active users and 1000 authentications per month, making it suitable for initial development and testing (SAWO pricing details).

  1. Sign up for a SAWO Labs account: Navigate to the SAWO Labs official website and complete the registration process. This typically involves providing an email address and setting a password for the dashboard.
  2. Access the SAWO Labs Dashboard: After successful registration and login, you will be redirected to the SAWO Labs Dashboard.
  3. Create a new application: Within the dashboard, locate the option to add or create a new application. You will need to provide basic information about your application, such as its name and type (e.g., Web, iOS, Android).
  4. Retrieve your API Key: Upon creating the application, the SAWO Dashboard will display a unique API Key. This key is essential for authenticating requests from your application to the SAWO Labs platform. Ensure this key is stored securely and not exposed in client-side code unless explicitly intended for a public client SDK. The SAWO Labs documentation provides specific guidance on managing API keys securely.
  5. Configure application settings (optional but recommended): Depending on your application type, you might need to configure additional settings in the dashboard, such as allowed callback URLs for web applications or package names for mobile applications.

It is critical to protect your API Key. For server-side integrations, environmental variables or secure configuration management systems are recommended. For client-side SDKs, the SAWO SDKs are designed to handle the public key securely within the context of the client application.

Your first request

After obtaining your API Key, the next step involves integrating a SAWO SDK into your application and making your first authentication request. The exact steps vary based on the platform you are targeting. SAWO Labs provides SDKs for web (JavaScript), Android, iOS, React Native, and Flutter, among others. For this example, we will focus on a basic web integration using the JavaScript SDK.

Before proceeding, ensure you have a basic web project set up. You can refer to the SAWO Web SDK Getting Started guide for detailed instructions.

1. Install the SAWO Web SDK

Include the SAWO Web SDK in your HTML file. You can load it via a CDN:

<script src="https://websdk.sawolabs.com/sawo.min.js"></script>

Alternatively, if you are using a package manager like npm, you can install it:

npm install sawo

And then import it into your JavaScript module:

import Sawo from 'sawo';

2. Initialize the SDK and implement the login form

Create an HTML element where the SAWO login form will be rendered:

<div id="sawo-container"></div>

Then, initialize the SAWO SDK with your API Key and a callback function to handle successful authentication:

const sawoConfig = {
  containerID: 'sawo-container', // This id is of the container where you want to display the sawo login form
  apiKey: 'YOUR_API_KEY_HERE', // Add your API key here
  identifierType: 'PHONE_SMS', // Can be 'EMAIL' or 'PHONE_SMS'
  onSuccess: payload => {
    console.log('Login successful!', payload);
    // Handle successful login, e.g., redirect user or update UI
    alert(`User logged in with identifier: ${payload.identifier}`);
  },
  onError: error => {
    console.error('Login error:', error);
    // Handle login errors
  },
  onFailure: error => {
    console.error('Login failed:', error);
    // Handle login failures
  }
};

const sawo = new Sawo(sawoConfig);
sawo.showForm();

Replace 'YOUR_API_KEY_HERE' with the API Key obtained from your SAWO Labs Dashboard. When this code runs in a browser, a SAWO login form will appear within the sawo-container div, prompting the user for their phone number or email, depending on the identifierType configured.

3. Test the authentication flow

Open your web page in a browser. You should see the SAWO login form. Enter a valid phone number or email address, and proceed with the authentication. Upon successful verification, the onSuccess callback function will execute, logging the authentication payload to the console. This payload typically contains information about the authenticated user and a unique user ID, which can be used for session management or further backend processing.

Common next steps

After successfully implementing your first passwordless authentication, developers typically explore the following areas:

  • User Session Management: Integrate the authentication payload received from SAWO Labs with your application's backend to establish and manage user sessions. This often involves issuing JWTs (JSON Web Tokens) or similar session tokens (RFC 7519 for JSON Web Token).
  • Backend Integration: For more secure operations or to retrieve user-specific data, integrate SAWO's backend APIs. This allows your server to verify authentication tokens, fetch user details, or manage user accounts more directly (SAWO Labs API Reference).
  • Multiple Identifier Types: Explore supporting different identifier types (e.g., both email and phone SMS) to offer users more flexibility in how they authenticate.
  • Custom UI and Branding: Customize the appearance of the SAWO login widget to match your application's branding guidelines, enhancing the user experience. The SAWO documentation provides details on UI customization options.
  • Error Handling and Edge Cases: Implement robust error handling for various scenarios, such as network issues, invalid inputs, or API limits.
  • Security Best Practices: Review SAWO Labs's security recommendations, especially regarding API key management and token validation, to ensure your integration is secure. For general API security, resources like Google's API Developers Guide offer foundational principles.
  • Explore Advanced Features: Investigate features like biometric authentication (if supported by the platform and user device) or integration with other identity providers.

Troubleshooting the first call

When encountering issues with your initial SAWO Labs integration, consider the following common troubleshooting steps:

  • Incorrect API Key: Double-check that the apiKey provided in your SDK initialization matches the API Key generated in your SAWO Labs Dashboard. Mismatches are a frequent source of authentication failures.
  • Container ID Mismatch: Ensure the containerID specified in the SAWO SDK configuration accurately corresponds to the id of the HTML element where you intend to render the login form.
  • Network Connectivity: Verify that your application has a stable internet connection and can reach SAWO Labs's servers. Browser developer tools (network tab) can help identify blocked requests or connection errors.
  • CORS Issues (Web SDK): For web applications, Cross-Origin Resource Sharing (CORS) policies might block requests if your domain is not properly configured in the SAWO Labs Dashboard. Ensure your web application's domain is whitelisted in your SAWO application settings.
  • SDK Not Loaded: Confirm that the SAWO SDK script is loaded correctly. Check the browser's developer console for any script loading errors.
  • Callback Function Errors: If the onSuccess or onError callbacks are not firing as expected, check for JavaScript errors within these functions. A syntax error or an unhandled exception within a callback could prevent it from executing fully.
  • Invalid Identifier Type: Ensure the identifierType (e.g., 'PHONE_SMS' or 'EMAIL') is correctly specified and that the input provided by the user matches this type.
  • Review SAWO Labs Documentation: The SAWO Labs official documentation provides specific troubleshooting sections for each SDK, offering detailed insights into common errors and their resolutions.
  • Check Dashboard Logs: The SAWO Labs Dashboard typically provides logs or analytics that can indicate whether authentication attempts are reaching the SAWO platform and if any errors are occurring on the server side.