The right authentication method depends on the client. A web app, a mobile app and an integration with a third-party service have different needs.

Ulabase supports several authentication methods on every service, and you choose the one that fits each client.

Two Ways to Authenticate

Ulabase provides two authentication mechanisms, and they work together. Basic Authentication is the simplest and works with every client. JWT tokens give you stateless authentication, and the Ulabase Kit uses them to keep the session of a web app. The sections below explain when and how to use each one.

Basic Authentication: Universal and Simple

Basic authentication works everywhere: browsers, mobile apps, API clients, and command-line tools. This makes it the usual choice for testing, development, and server-to-server communication.

How It Works

Send the credentials in the Authorization header, here with curl:

curl -u alice:her-password \
  https://c0ffee.ulabase.app/orders

Or in your JavaScript app:

fetch('https://c0ffee.ulabase.app/orders', {
  headers: {
    'Authorization': 'Basic ' + btoa('alice:her-password')
  }
})

When to Use Basic Auth

Basic Auth fits four cases. In testing and development it lets you verify an API call quickly. In server-to-server communication it is simple to set up. API integrations and command-line tools support it without extra code. In a quick prototype it works with no setup.

The JWT Upgrade

Send the credentials once to /token with Basic Auth, and the response carries a JWT in the Auth-Token header. You start with the simple method and continue with the token.

# Sign in with Basic Auth
curl -i -u alice:her-password -X POST \
  https://c0ffee.ulabase.app/token

# Response includes:
# Auth-Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Then send the JWT in the following requests:

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  https://c0ffee.ulabase.app/orders

JWT Authentication: Modern and Stateless

JSON Web Tokens (JWT) are a widely used standard for API authentication. A token is signed and self-contained, so the server keeps no session.

Why JWT?

A JWT is stateless: the server needs no session storage. The same token works across multiple servers, which suits distributed architectures. Each token is self-contained and carries the user's identity and roles. The JWT standard is supported across platforms and languages, so it integrates with any technology stack.

Using JWT Tokens

Once you have a token, send it in the Authorization header:

// In your frontend app
const token = localStorage.getItem('authToken');

fetch('https://c0ffee.ulabase.app/orders', {
  headers: {
    'Authorization': `Bearer ${token}`
  }
})

Token Lifecycle

Tokens expire, so a stolen token is useful for a limited time. Before it expires, the client renews it with GET /token?renew=true. To log out, discard the token on the client.

Web Apps: the Kit Keeps the Session

A web app talks to its service from another site: the app is on your domain, the service on *.ulabase.app. A cookie set by the service would be a third-party cookie, which Safari and Firefox block by default. For this reason a service sets no cookie, and a web app sends the token as a Bearer header.

The Ulabase Kit does this for React, Angular and Vue. It signs the user in, keeps the token, renews it before it expires, and restores the session after a reload.

// Sign in with the Kit: the token is stored and renewed for you
await login(config, 'alice@example.com', 'her-password');

Next.js and Nuxt can keep the session in a cookie of their own. Your server sets it, first-party, holding the same bearer token. The Kit's /next and /nuxt subpaths do this for you.

Choosing the Right Method

Basic Auth: Development & Testing

// Quick testing
fetch('https://c0ffee.ulabase.app/orders', {
  headers: {
    'Authorization': 'Basic ' + btoa('alice:her-password')
  }
})

JWT: Mobile & API Clients

// Mobile app or API integration
const token = await secureStorage.get('authToken');
fetch('https://c0ffee.ulabase.app/orders', {
  headers: {
    'Authorization': `Bearer ${token}`
  }
})

The Kit: Web Applications

// SPA or web app: the Kit adds the Bearer header to its calls
const user = await getUserInfo(config);

OAuth Integration

Ulabase also supports login with Google. Users sign in with their existing account, and the service hands your app a JWT that works like any other.

// After the OAuth login redirect
// the Kit reads the token from the URL fragment and stores it
// Use it like any other JWT token

Mix and Match

You can use different methods in different parts of your application. Your web frontend can use the Kit, while your mobile app sends JWT tokens. Admin scripts can use Basic Auth, and third-party integrations can use an API key issued by a user. All of these approaches work with the same user database, the same permissions, and the same security model.

Security Built In

The same protections apply to every method. Passwords are stored hashed. Tokens are signed, and the signature is verified, so a tampered token is rejected. Every service is served over HTTPS, which protects credentials in transit. The platform handles token expiration.

Start Building

With Ulabase, authentication is ready when the service is created. Basic Auth works on the first request, and POST /token gives you a JWT. The Kit keeps the session of your web app. You choose no authentication library and configure no session storage.

Learn More

For detailed API documentation and advanced configuration:

Authentication Documentation

Ready to Build?

Create a free Ulabase service and start authenticating users.

Try Ulabase for free →

Build your app on Ulabase

Your backend is ready in minutes, and you spend your time on your app. The Free plan needs no credit card.