Create Passkey Over Open Session
The simplest and most unrestricted user signup flow, where username and passkey credential is created immediately upon successful sdk called.
To ensure open session, make sure you application is setup with Registration Requires Authentication Token is disabled in your application settings.

When this setting is disabled, users can be created and passkeys can be generated without requiring any authorization tokens. This allows you to simplify the registration in public-facing applications that don’t need strict authentication during the sign-up process.
Here is how it might look like:



Prerequisites
- Create an application to obtain a base URL. The SDK uses this base URL to interact with the LoginID authentication service.
Setup SDK
- Javascript
- Kotlin
- Swift
npm i @loginid/websdk3
Import and initialize an instance:
import { LoginIDWebSDK } from "@loginid/websdk3";
const lid = new LoginIDWebSDK({
baseUrl: process.env.LOGINID_BASE_URL,
});
To obtain the SDK:
- Go to the LoginID Dashboard and select one of your apps.
- Open the Get Started section and choose the Android icon.
- Follow the instructions to download the binary
.aarfile and include it in your project.
Initialize a singleton configuration for the LoginID service in the application's onCreate method.
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
// Initialize the singleton instance
val config = LoginIDServiceConfig("<BASE_URL>")
LoginID.configure(config).client()
}
}
To obtain the SDK:
- Go to the LoginID Dashboard and select one of your apps.
- Open the Get Started section and choose the iOS icon.
- Follow the instructions to download the binary
xcframeworkfile and include it in your project.
Configure the singleton instance of LoginIDSDK with a base URL during the app's launch in the App struct initializer.
import SwiftUI
import LoginID
@main
struct MyApp: App {
init() {
let baseUrl = "<BASE_URL>"
// Initialize the singleton instance
LoginIDSDK.shared.configure(baseUrl: baseUrl)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Creating a Passkey For a New User
Call the createPasskey method by passing in the email or username.
If you run into issues, be sure to check the Troubleshooting section. Since implementing passkey creation is often one of the first steps in integration, reviewing common issues early can help you resolve problems faster.
- Javascript
- Kotlin
- Swift
import { LoginIDWebSDK } from "@loginid/websdk3";
// Obtain credentials from LoginID Tenant
const BASE_URL = process.env.BASE_URL;
const APP_ID = process.env.APP_ID;
// Initialize the SDK with your configuration
const config = {
baseUrl: BASE_URL,
appId: APP_ID,
};
// Use the SDK components for signup and signin
const lid = new LoginIDWebSDK(config);
// Button click handler
async function handleSignupButtonClick() {
const username = "billy@loginid.io";
try {
// Sign up with a passkey
const authResult = await lid.createPasskey(username);
setAuthUser(user);
} catch (error) {
// Handle errors
console.error("Error during signup:", error);
}
}
// Attach the click handler to a button
const signupButton = document.getElementById("signupButton");
signinButton.addEventListener("click", handleSigninButtonClick);
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import loginid.LoginID
import services.LoginIDServiceConfig
import services.exceptions.LoginIDError
import services.modals.CreatePasskeyOptions
class MainActivity : AppCompatActivity() {
companion object {
private val config = LoginIDServiceConfig("<BASE_URL>", "<APP_ID>")
val lid = LoginID(config)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val registerButton = findViewById<Button>(R.id.registerBtn)
registerButton.setOnClickListener {
registerUser("billy@loginid.io", null)
}
}
private fun registerUser(username: String, options: CreatePasskeyOptions?) {
lifecycleScope.launch {
try {
lid.registerWithPasskey(this@MainActivity, username, options)
} catch (e: Exception) {
if (e is LoginIDError) {
// Handle LoginIDError specifically
} else {
// Handle other exceptions
}
}
}
}
}
import SwiftUI
import LoginID
@main
struct ExampleApp: App {
@State private var errorMessage: String? = nil
@State private var username: String = "user@example.com"
init() {
// Configure the LoginID SDK
LoginIDSDK.shared.configure(
baseUrl: "<BASE_URL>",
)
}
var body: some Scene {
WindowGroup {
VStack {
Button("Register with Passkey") {
Task {
await registerUser()
}
}
.padding()
}
}
}
private func registerUser() async {
do {
_ = try await LoginIDSDK.shared.createPasskey(
username: username,
authzToken: nil,
options: nil
)
} catch let error as LoginIDError {
errorMessage = error.message
} catch {
errorMessage = error.localizedDescription
}
}
}