Authentication

circle-info

💡 bkend provides various authentication methods including email, social login, and magic link.

Overview

To separate data per user and enforce permissions like "only the author can edit their own posts," you need user authentication.

The bkend authentication system is a core feature that manages Users in your project. It provides authentication features through REST API, from sign-up and sign-in to session management and multi-factor authentication (MFA).


Authentication Decision Tree

The following diagram guides you on which authentication method to use when calling the API.

spinner
Auth Method
Use Case
Header

JWT (User Token)

API calls on behalf of a user from the app

Authorization: Bearer {accessToken}

API Key (Publishable)

Client-side API calls

X-API-Key: pk_...

API Key (Secret)

Server-side API calls

X-API-Key: sk_...

No Auth

Public endpoints (isPublic)

None


Authentication Methods

bkend supports the following authentication methods.

Method
Description
Use Case

Email + Password

Traditional email/password authentication

General web/app services

Magic Link

Sends a one-time login link via email

Passwordless sign-in

Google OAuth

Social login with Google account

Quick social login

GitHub OAuth

Social login with GitHub account

Developer-oriented services


Authentication Flow

spinner

JWT Tokens

bkend uses JWT (JSON Web Token) based authentication.

Token
Purpose
Validity

Access Token

Included in auth header for API requests

Short-lived (default 1 hour)

Refresh Token

Renew Access Token when expired

Long-lived (default 7 days)

Authorization Header

circle-exclamation

Required Headers

All authentication API requests require the following headers.

Header
Value
Required
Description

X-API-Key

{pk_publishable_key}

Yes

Publishable Key issued from the console

Authorization

Bearer {accessToken}

Conditional

For endpoints that require authentication

circle-info

💡 You can issue a Publishable Key from the console. See API Keys for details.


User Roles

Users registered in a bkend project can have the following roles.

Role
Description

admin

Administrator -- full access to all data

user

Regular user -- default role

guest

Guest -- limited access

Data access permissions vary by role. See RLS Policies for details.


Key Features

Account Management

Social Login

Security

User Management

Settings


Next Steps

Last updated