Appearance
Fresh 🌱
Hosted UI
The simplest way to create authenticated browser sessions
Collect credentials securely via Kernel's hosted page, then use the authenticated session in your automations. This is the recommended approach for most applications.
Use the Hosted UI when:
- You need users to provide their credentials
- You want the simplest integration with minimal code
- You want Kernel to handle 2FA and multi-step login flows
Getting started
1. Create a Connection
A Managed Auth Connection attaches an authenticated domain to a profile so you can use the auth connection in future browsers. You can attach multiple auth connections to the same profile , one per domain , to keep several sites authenticated at once.
typescript
const auth = await kernel.auth.connections.create({
domain: 'linkedin.com',
profile_name: 'linkedin-profile', // Name of the profile to associate with the connection
});python
auth = await kernel.auth.connections.create(
domain="linkedin.com",
profile_name="linkedin-profile", # Name of the profile to associate with the connection
)2. Start a Login Session
Start a Managed Auth Session to get the hosted login URL.
typescript
const login = await kernel.auth.connections.login(auth.id);python
login = await kernel.auth.connections.login(auth.id)3. Collect Credentials
Send the user to the hosted login page:
typescript
window.location.href = login.hosted_url;python
# Return the URL to your frontend
print(f"Redirect to: {login.hosted_url}")The user will:
- See the login page for the target website
- Enter their credentials
- Complete 2FA if needed
4. Poll for Completion
On your backend, poll until authentication completes:
typescript
let state = await kernel.auth.connections.retrieve(auth.id);
while (state.flow_status === 'IN_PROGRESS') {
await new Promise(r => setTimeout(r, 2000));
state = await kernel.auth.connections.retrieve(auth.id);
}
if (state.status === 'AUTHENTICATED') {
console.log('Authentication successful!');
}python
state = await kernel.auth.connections.retrieve(auth.id)
while state.flow_status == "IN_PROGRESS":
await asyncio.sleep(2)
state = await kernel.auth.connections.retrieve(auth.id)
if state.status == "AUTHENTICATED":
print("Authentication successful!")INFO
Poll every 2 seconds. The session expires after 20 minutes if not completed, and the flow times out after 10 minutes of waiting for user input.
5. Use the Profile
Create browsers with the profile and navigate to the site. The browser session will already be authenticated:
typescript
const browser = await kernel.browsers.create({
profile: { name: 'linkedin-profile' },
stealth: true,
});
// Navigate to the site, you're already logged in
await page.goto('https://linkedin.com');python
browser = await kernel.browsers.create(
profile={"name": "linkedin-profile"},
stealth=True,
)
# Navigate to the site, you're already logged in
await page.goto("https://linkedin.com")INFO
Managed Auth Connections are generated using Kernel's stealth mode. Use stealth: true when creating authenticated browser sessions for the best experience.
Complete Example
typescript
import Kernel from '@onkernel/sdk';
const kernel = new Kernel();
// Create connection
const auth = await kernel.auth.connections.create({
domain: 'doordash.com',
profile_name: 'doordash-user-123',
});
// Start authentication
const login = await kernel.auth.connections.login(auth.id);
// Send user to hosted page
console.log('Login URL:', login.hosted_url);
// Poll for completion
let state = await kernel.auth.connections.retrieve(auth.id);
while (state.flow_status === 'IN_PROGRESS') {
await new Promise(r => setTimeout(r, 2000));
state = await kernel.auth.connections.retrieve(auth.id);
}
if (state.status === 'AUTHENTICATED') {
const browser = await kernel.browsers.create({
profile: { name: 'doordash-user-123' },
stealth: true,
});
// Navigate to the site, you're already logged in
await page.goto('https://doordash.com');
}python
from kernel import Kernel
import asyncio
kernel = Kernel()
# Create connection
auth = await kernel.auth.connections.create(
domain="doordash.com",
profile_name="doordash-user-123",
)
# Start authentication
login = await kernel.auth.connections.login(auth.id)
# Send user to hosted page
print(f"Login URL: {login.hosted_url}")
# Poll for completion
state = await kernel.auth.connections.retrieve(auth.id)
while state.flow_status == "IN_PROGRESS":
await asyncio.sleep(2)
state = await kernel.auth.connections.retrieve(auth.id)
if state.status == "AUTHENTICATED":
browser = await kernel.browsers.create(
profile={"name": "doordash-user-123"},
stealth=True,
)
# Navigate to the site, you're already logged in
await page.goto("https://doordash.com")Connection Configuration
Connection-level options , custom login URL, SSO/OAuth, custom proxy, session recording, post-login URL, and updates , apply equally to all integration flows and are documented in Connection Configuration.